macadeliccc
commited on
Commit
•
1ff8d2c
1
Parent(s):
b171572
Update README.md
Browse files
README.md
CHANGED
@@ -13,4 +13,66 @@ The model is a merge of models that are capable of Chinese and Japanese output.
|
|
13 |
+ oshizo/japanese-e5-mistral-7b_slerp
|
14 |
+ cognitivecomputations/dolphin-2.6-mistral-7b-dpo-laser
|
15 |
+ s3nh/Mistral-7B-Evol-Instruct-Chinese
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
+ oshizo/japanese-e5-mistral-7b_slerp
|
14 |
+ cognitivecomputations/dolphin-2.6-mistral-7b-dpo-laser
|
15 |
+ s3nh/Mistral-7B-Evol-Instruct-Chinese
|
16 |
+
|
17 |
+
|
18 |
+
# Code Example
|
19 |
+
|
20 |
+
```python
|
21 |
+
# Import necessary libraries
|
22 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
23 |
+
|
24 |
+
# Load tokenizer and model
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained("macadeliccc/laser-dolphin-mixtral-2x7b-dpo")
|
26 |
+
model = AutoModelForCausalLM.from_pretrained("macadeliccc/laser-dolphin-mixtral-2x7b-dpo")
|
27 |
+
|
28 |
+
def generate_response(prompt, max_length=50, num_return_sequences=1, temperature=1.0, top_k=50, top_p=1.0):
|
29 |
+
"""
|
30 |
+
Generate a response from the model based on the input prompt and hyperparameters.
|
31 |
+
|
32 |
+
Args:
|
33 |
+
prompt (str): Prompt for the model.
|
34 |
+
max_length (int): Maximum length of the model's response.
|
35 |
+
num_return_sequences (int): Number of response sequences to generate.
|
36 |
+
temperature (float): Sampling temperature for model generation.
|
37 |
+
top_k (int): The number of highest probability vocabulary tokens to keep for top-k filtering.
|
38 |
+
top_p (float): If set to float < 1, only the most probable tokens with probabilities that add up to top_p or higher are kept for generation.
|
39 |
+
|
40 |
+
Returns:
|
41 |
+
str: The generated response from the model.
|
42 |
+
"""
|
43 |
+
messages = [
|
44 |
+
{"role": "system", "content": "You are Dolphin, an AI assistant."},
|
45 |
+
{"role": "user", "content": prompt}
|
46 |
+
]
|
47 |
+
|
48 |
+
# Apply chat template to input messages
|
49 |
+
gen_input = tokenizer.apply_chat_template(messages, return_tensors="pt")
|
50 |
+
|
51 |
+
# Generate a response
|
52 |
+
output = model.generate(**gen_input,
|
53 |
+
max_length=max_length,
|
54 |
+
num_return_sequences=num_return_sequences,
|
55 |
+
temperature=temperature,
|
56 |
+
top_k=top_k,
|
57 |
+
top_p=top_p)
|
58 |
+
|
59 |
+
# Decode the generated tokens to a string
|
60 |
+
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
61 |
+
|
62 |
+
return response
|
63 |
+
|
64 |
+
# Example prompts in different languages
|
65 |
+
english_prompt = "Write a quicksort algorithm in python"
|
66 |
+
chinese_prompt = "用Python写一个快速排序算法"
|
67 |
+
japanese_prompt = "Pythonでクイックソートアルゴリズムを書いてください"
|
68 |
+
|
69 |
+
# Generate and print responses for each language
|
70 |
+
print("English Response:")
|
71 |
+
print(generate_response(english_prompt, max_length=100, temperature=0.8), "\n")
|
72 |
+
|
73 |
+
print("Chinese Response:")
|
74 |
+
print(generate_response(chinese_prompt, max_length=100, temperature=0.8), "\n")
|
75 |
+
|
76 |
+
print("Japanese Response:")
|
77 |
+
print(generate_response(japanese_prompt, max_length=100, temperature=0.8), "\n")
|
78 |
+
```
|