File size: 1,593 Bytes
a3bff06 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
## Run the model
### Instruction format
The template used to build a prompt for this Instruct model is defined as follows:
```
### USER:
{instruction1}
### RESPONSE:
{respone1}
### USER:
{instruction2}
### RESPONSE:
{respone2}
```
Run the model with the transformers library:
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "tktung/MultiSV_Mixtral-8x7B-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id,
device_map="auto",
dtype=torch.float16 # optional, load in 16-bit precision mode to reduce memory usage
)
model.eval()
def make_prompt(instruction):
return f"""### USER:
{instruction}
### RESPONSE:
"""
user_input = "Känner du till WARA M&L?"
input_prompt = make_prompt(user_input)
input_ids = tokenizer(input_prompt, return_tensors="pt")["input_ids"]
generated_token_ids = model.generate(
inputs=input_ids,
max_new_tokens=100,
do_sample=True,
temperature=0.6,
top_p=1,
)[0]
generated_text = tokenizer.decode(generated_token_ids)
```
### Retrieval Augmented Generation
The model was trained with the following prompt format for RAG:
Vietnamese:
```
### USER:
Sử dụng ngữ cảnh sau để trả lời câu hỏi ở cuối:
{context}
Câu hỏi: {human_prompt}
### RESPONSE:
```
Swedish:
```
### USER:
Använd följande sammanhang för att svara på frågan:
{context}
Fråga: {human_prompt}
### RESPONSE:
``` |