Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,97 @@
|
|
1 |
---
|
2 |
license: llama2
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: llama2
|
3 |
---
|
4 |
+
|
5 |
+
# youri-2x7b_v0.2
|
6 |
+
|
7 |
+
This model is a Mixture of Experts (MoE) merger of the following two models:
|
8 |
+
- [rinna/youri-7b-instruction](https://huggingface.co/rinna/youri-7b-instruction)
|
9 |
+
- [rinna/youri-7b-chat](https://huggingface.co/rinna/youri-7b-chat)
|
10 |
+
|
11 |
+
## 🧩 Configuration
|
12 |
+
|
13 |
+
The model has been made with a custom version of the [mergekit](https://github.com/cg123/mergekit) library (mixtral branch) and the following configuration:
|
14 |
+
|
15 |
+
```yaml
|
16 |
+
base_model: rinna/youri-7b-chat
|
17 |
+
gate_mode: hidden # one of "hidden", "cheap_embed", or "random"
|
18 |
+
dtype: bfloat16 # output dtype (float32, float16, or bfloat16)
|
19 |
+
experts:
|
20 |
+
- source_model: rinna/youri-7b-chat
|
21 |
+
positive_prompts:
|
22 |
+
- "質問と回答の選択肢を入力として受け取り、選択肢から回答を選択してください。"
|
23 |
+
- "前提と仮説の関係を含意、矛盾、中立の中から回答してください。"
|
24 |
+
- "以下のテキストを、ポジティブまたはネガティブの感情クラスのいずれかに分類してください。"
|
25 |
+
- "与えられた問題に対して、ステップごとに答えを導き出してください。"
|
26 |
+
- source_model: rinna/youri-7b-instruction
|
27 |
+
positive_prompts:
|
28 |
+
- "質問に対する回答を題名と文章から一言で抽出してください。回答は名詞で答えてください。"
|
29 |
+
- "与えられたニュース記事を要約してください。"
|
30 |
+
- "与えられた文が文法的であるかを回答してください。"
|
31 |
+
```
|
32 |
+
|
33 |
+
The `positive_prompts` in the above configuration are extracted from the instructions of benchmarks that each model excels in.
|
34 |
+
For reference on the benchmarks for each model, please see the LM Benchmark at [rinna's LM Benchmark](https://rinnakk.github.io/research/benchmarks/lm/index.html).
|
35 |
+
These benchmarks provide a detailed overview of the areas where each individual model performs particularly well, guiding the effective use of the merged model in various natural language processing tasks.
|
36 |
+
|
37 |
+
## 💻 Usage
|
38 |
+
|
39 |
+
Here's a [Colab notebook](https://colab.research.google.com/drive/1k6C_oJfEKUq0mtuWKisvoeMHxTcIxWRa?usp=sharing) to run Phixtral in 4-bit precision on a free T4 GPU.
|
40 |
+
|
41 |
+
```python
|
42 |
+
!pip install -q --upgrade transformers einops accelerate bitsandbytes
|
43 |
+
|
44 |
+
import torch
|
45 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
46 |
+
|
47 |
+
model_name = "HachiML/youri-2x7b_v0.2"
|
48 |
+
torch.set_default_device("cuda")
|
49 |
+
|
50 |
+
# Load the model and tokenizer
|
51 |
+
model = AutoModelForCausalLM.from_pretrained(
|
52 |
+
model_name,
|
53 |
+
torch_dtype="auto",
|
54 |
+
load_in_4bit=True,
|
55 |
+
trust_remote_code=True
|
56 |
+
)
|
57 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
58 |
+
model_name,
|
59 |
+
trust_remote_code=True
|
60 |
+
)
|
61 |
+
|
62 |
+
torch.set_default_device("cuda")
|
63 |
+
|
64 |
+
# Create input
|
65 |
+
instruction = "次の日本語を英語に翻訳してください。"
|
66 |
+
input = "大規模言語モデル(だいきぼげんごモデル、英: large language model、LLM)は、多数のパラメータ(数千万から数十億)を持つ人工ニューラルネットワークで構成されるコンピュータ言語モデルで、膨大なラベルなしテキストを使用して自己教師あり学習または半教師あり学習によって訓練が行われる。"
|
67 |
+
prompt = f"""
|
68 |
+
以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。
|
69 |
+
|
70 |
+
### 指示:
|
71 |
+
{instruction}
|
72 |
+
|
73 |
+
### 入力:
|
74 |
+
{input}
|
75 |
+
|
76 |
+
### 応答:
|
77 |
+
"""
|
78 |
+
|
79 |
+
# Tokenize the input string
|
80 |
+
token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
|
81 |
+
|
82 |
+
# Generate text using the model
|
83 |
+
with torch.no_grad():
|
84 |
+
output_ids = model.generate(
|
85 |
+
token_ids.to(model.device),
|
86 |
+
max_new_tokens=200,
|
87 |
+
do_sample=True,
|
88 |
+
temperature=0.5,
|
89 |
+
pad_token_id=tokenizer.pad_token_id,
|
90 |
+
bos_token_id=tokenizer.bos_token_id,
|
91 |
+
eos_token_id=tokenizer.eos_token_id
|
92 |
+
)
|
93 |
+
|
94 |
+
# Decode and print the output
|
95 |
+
output = tokenizer.decode(output_ids.tolist()[0])
|
96 |
+
print(output)
|
97 |
+
```
|