ahmedsamirio
commited on
Commit
•
531194b
1
Parent(s):
987eb03
Updated inference code in README.md
Browse files
README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
---
|
2 |
base_model: meta-llama/Meta-Llama-3-8B
|
3 |
-
library_name: peft
|
4 |
license: llama3
|
5 |
tags:
|
6 |
- axolotl
|
7 |
- generated_from_trainer
|
8 |
model-index:
|
9 |
-
- name:
|
10 |
results: []
|
11 |
---
|
12 |
|
@@ -113,6 +112,72 @@ This model is an attempt to create a small translation model from English to Egy
|
|
113 |
|
114 |
- Translating instruction finetuning and text generation datasets
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
## Training and evaluation data
|
117 |
|
118 |
[ahmedsamirio/oasst2-9k-translation](https://huggingface.co/datasets/ahmedsamirio/oasst2-9k-translation)
|
|
|
1 |
---
|
2 |
base_model: meta-llama/Meta-Llama-3-8B
|
|
|
3 |
license: llama3
|
4 |
tags:
|
5 |
- axolotl
|
6 |
- generated_from_trainer
|
7 |
model-index:
|
8 |
+
- name: Egyptian-Arabic-Translator-Llama-3-8B
|
9 |
results: []
|
10 |
---
|
11 |
|
|
|
112 |
|
113 |
- Translating instruction finetuning and text generation datasets
|
114 |
|
115 |
+
## Inference code
|
116 |
+
|
117 |
+
```python
|
118 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
119 |
+
|
120 |
+
tokenizer = AutoTokenizer.from_pretrained("ahmedsamirio/Egyptian-Arabic-Translator-Llama-3-8B")
|
121 |
+
model = AutoModelForCausalLM.from_pretrained("ahmedsamirio/Egyptian-Arabic-Translator-Llama-3-8B")
|
122 |
+
pipe = pipeline(task='text-generation', model=model, tokenizer=tokenizer)
|
123 |
+
|
124 |
+
|
125 |
+
en_template = """<|begin_of_text|>Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
126 |
+
|
127 |
+
### Instruction:
|
128 |
+
Translate the following text to English.
|
129 |
+
|
130 |
+
### Input:
|
131 |
+
{text}
|
132 |
+
|
133 |
+
### Response:
|
134 |
+
"""
|
135 |
+
|
136 |
+
ar_template = """<|begin_of_text|>Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
137 |
+
|
138 |
+
### Instruction:
|
139 |
+
Translate the following text to Arabic.
|
140 |
+
|
141 |
+
### Input:
|
142 |
+
{text}
|
143 |
+
|
144 |
+
### Response:
|
145 |
+
"""
|
146 |
+
|
147 |
+
eg_template = """<|begin_of_text|>Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
148 |
+
|
149 |
+
### Instruction:
|
150 |
+
Translate the following text to Egyptian Arabic.
|
151 |
+
|
152 |
+
### Input:
|
153 |
+
{text}
|
154 |
+
|
155 |
+
### Response:
|
156 |
+
"""
|
157 |
+
|
158 |
+
text = """Some habits are known as "keystone habits," and these influence the formation of other habits. \
|
159 |
+
For example, identifying as the type of person who takes care of their body and is in the habit of exercising regularly, \
|
160 |
+
can also influence eating better and using credit cards less. In business, \
|
161 |
+
safety can be a keystone habit that influences other habits that result in greater productivity.[17]"""
|
162 |
+
|
163 |
+
ar_text = pipe(ar_template.format(text=text),
|
164 |
+
max_new_tokens=256,
|
165 |
+
do_sample=True,
|
166 |
+
temperature=0.3,
|
167 |
+
top_p=0.5)
|
168 |
+
|
169 |
+
|
170 |
+
eg_text = pipe(eg_template.format(text=ar_text),
|
171 |
+
max_new_tokens=256,
|
172 |
+
do_sample=True,
|
173 |
+
temperature=0.3,
|
174 |
+
top_p=0.5)
|
175 |
+
|
176 |
+
print("Original Text:" text)
|
177 |
+
print("\nArabic Translation:", ar_text)
|
178 |
+
print("\nEgyptian Arabic Translation:", eg_text)
|
179 |
+
```
|
180 |
+
|
181 |
## Training and evaluation data
|
182 |
|
183 |
[ahmedsamirio/oasst2-9k-translation](https://huggingface.co/datasets/ahmedsamirio/oasst2-9k-translation)
|