add readme file
Browse files
README.md
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- hdeldar/Persian-Text-llama2-1k
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
---
|
7 |
+
# π¦π§ Persion-Text-llama2-7b-1k
|
8 |
+
|
9 |
+
π [Article](https://towardsdatascience.com/fine-tune-your-own-llama-2-model-in-a-colab-notebook-df9823a04a32) |
|
10 |
+
π» [Colab](https://colab.research.google.com/drive/1PEQyJO1-f6j0S_XJ8DV50NkpzasXkrzd?usp=sharing) |
|
11 |
+
π [Script](https://gist.github.com/mlabonne/b5718e1b229ce6553564e3f56df72c5c)
|
12 |
+
|
13 |
+
<center><img src="https://i.imgur.com/1IZmjU4.png" width="300"></center>
|
14 |
+
|
15 |
+
This is a `Llama-2-7b-chat-hf` model fine-tuned using QLoRA (4-bit precision) on the [`hdeldar/Persian-Text-llama2-1k`](https://huggingface.co/datasets/hdeldar/Persian-Text-llama2-1k) dataset, which is a subset of the [`SeyedAli/Persian-Text-QA`](https://huggingface.co/datasets/SeyedAli/Persian-Text-QA).
|
16 |
+
|
17 |
+
## π§ Training
|
18 |
+
|
19 |
+
It was trained on a Google Colab notebook with a T4 GPU and high RAM. It is mainly designed for educational purposes, not for inference.
|
20 |
+
|
21 |
+
## π» Usage
|
22 |
+
|
23 |
+
``` python
|
24 |
+
# pip install transformers accelerate
|
25 |
+
|
26 |
+
from transformers import AutoTokenizer
|
27 |
+
import transformers
|
28 |
+
import torch
|
29 |
+
|
30 |
+
model = "hdeldar/llama-2-7b-persian-text-1k"
|
31 |
+
prompt = "What is a large language model?"
|
32 |
+
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
34 |
+
pipeline = transformers.pipeline(
|
35 |
+
"text-generation",
|
36 |
+
model=model,
|
37 |
+
torch_dtype=torch.float16,
|
38 |
+
device_map="auto",
|
39 |
+
)
|
40 |
+
|
41 |
+
sequences = pipeline(
|
42 |
+
f'<s>[INST] {prompt} [/INST]',
|
43 |
+
do_sample=True,
|
44 |
+
top_k=10,
|
45 |
+
num_return_sequences=1,
|
46 |
+
eos_token_id=tokenizer.eos_token_id,
|
47 |
+
max_length=200,
|
48 |
+
)
|
49 |
+
for seq in sequences:
|
50 |
+
print(f"Result: {seq['generated_text']}")
|
51 |
+
```
|
52 |
+
|
53 |
+
Output:
|
54 |
+
> A large language model is trained on massive amounts of text data to understand and generate human language. The model learns by predicting the next word in a sequence based on the context of the previous words. This process allows the language model to learn patterns, rules, and relationships within the language that allow it to generate text that looks and sounds authentic and coherent. These large language models are used for many applications, such as language translation, sentiment analysis, and language generation. These models can also be used to generate text summaries of complex documents, such as legal or scientific papers, or to generate text summaries of social media posts. These models are often used in natural language processing (NLP) and machine learning applications.
|
55 |
+
> The large language models are trained using a large number of parameters, often in the billions or even in the tens of billions.
|