bofenghuang
commited on
Commit
•
2220ca6
1
Parent(s):
b4345aa
Update README
Browse files- README.md +30 -72
- vigogne_logo.png +0 -0
README.md
CHANGED
@@ -1,97 +1,55 @@
|
|
1 |
---
|
2 |
-
license:
|
3 |
-
language:
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
12 |
|
|
|
|
|
|
|
13 |
|
14 |
## Usage
|
15 |
|
|
|
|
|
16 |
```python
|
17 |
-
import torch
|
18 |
from peft import PeftModel
|
19 |
-
from transformers import
|
20 |
-
|
21 |
-
PROMPT_DICT = {
|
22 |
-
"prompt_input": (
|
23 |
-
"Ci-dessous se trouve une instruction qui décrit une tâche, associée à une entrée qui fournit un contexte supplémentaire. Écrivez une réponse qui complète correctement la demande.\n\n"
|
24 |
-
"### Instruction:\n{instruction}\n\n### Entrée:\n{input}\n\n### Réponse:\n"
|
25 |
-
),
|
26 |
-
"prompt_no_input": (
|
27 |
-
"Ci-dessous se trouve une instruction qui décrit une tâche. Écrivez une réponse qui complète correctement la demande.\n\n"
|
28 |
-
"### Instruction:\n{instruction}\n\n### Réponse:\n"
|
29 |
-
),
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
device = "cuda"
|
34 |
|
35 |
tokenizer = LlamaTokenizer.from_pretrained("decapoda-research/llama-7b-hf")
|
36 |
model = LlamaForCausalLM.from_pretrained(
|
37 |
"decapoda-research/llama-7b-hf",
|
38 |
load_in_8bit=True,
|
39 |
-
torch_dtype=torch.float16,
|
40 |
device_map="auto",
|
41 |
)
|
42 |
-
model = PeftModel.from_pretrained(
|
43 |
-
|
44 |
-
"bofenghuang/vigogne-lora-7b",
|
45 |
-
torch_dtype=torch.float16,
|
46 |
-
)
|
47 |
|
|
|
48 |
|
49 |
-
|
50 |
-
instruction,
|
51 |
-
input=None,
|
52 |
-
temperature=0.1,
|
53 |
-
top_p=1.0,
|
54 |
-
max_new_tokens=512,
|
55 |
-
**kwargs,
|
56 |
-
):
|
57 |
-
prompt = (
|
58 |
-
PROMPT_DICT["prompt_input"].format_map({"instruction": instruction, "input": input})
|
59 |
-
if input is not None
|
60 |
-
else PROMPT_DICT["prompt_no_input"].format_map({"instruction": instruction})
|
61 |
-
)
|
62 |
-
tokenized_inputs = tokenizer(prompt, return_tensors="pt")
|
63 |
-
input_ids = tokenized_inputs["input_ids"].to(device)
|
64 |
-
generation_config = GenerationConfig(
|
65 |
-
temperature=temperature,
|
66 |
-
top_p=top_p,
|
67 |
-
**kwargs,
|
68 |
-
)
|
69 |
-
with torch.inference_mode():
|
70 |
-
generation_output = model.generate(
|
71 |
-
input_ids=input_ids,
|
72 |
-
generation_config=generation_config,
|
73 |
-
return_dict_in_generate=True,
|
74 |
-
output_scores=True,
|
75 |
-
max_new_tokens=max_new_tokens,
|
76 |
-
)
|
77 |
-
s = generation_output.sequences[0]
|
78 |
-
output = tokenizer.decode(s)
|
79 |
-
return output.split("### Réponse:")[1].strip()
|
80 |
|
81 |
-
|
82 |
-
instruct("Expliquer le théorème central limite.")
|
83 |
-
# Le théorème central limite stipule que la loi de la moyenne des valeurs aléatoires d'une série de variables aléatoires est la loi normale.
|
84 |
-
# Cela signifie que la moyenne des valeurs aléatoires d'une série de variables aléatoires tend vers la loi normale, indépendamment de la taille de la série.
|
85 |
|
86 |
-
|
87 |
-
instruct(
|
88 |
-
"Traduisez le texte suivant en français.",
|
89 |
-
input="Caterpillars extract nutrients which are then converted into butterflies. People have extracted billions of nuggets of understanding and GPT-4 is humanity's butterfly.",
|
90 |
-
)
|
91 |
-
# Les papillons de nuit extraient des nutriments qui sont ensuite convertis en papillons. Les gens ont extrait des milliards de nuggets de compréhension et GPT-4 est la butterfly de l'humanité.
|
92 |
-
```
|
93 |
|
|
|
94 |
|
95 |
-
## Todo
|
96 |
- Add output examples
|
97 |
-
- Open source github repo
|
|
|
1 |
---
|
2 |
+
license: openrail
|
3 |
+
language:
|
4 |
+
- fr
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
library_name: transformers
|
7 |
+
tags:
|
8 |
+
- alpaca
|
9 |
+
- llama
|
10 |
+
- LLM
|
11 |
+
datasets:
|
12 |
+
- tatsu-lab/alpaca
|
13 |
+
inference: false
|
14 |
---
|
15 |
|
16 |
+
<p align="center" width="100%">
|
17 |
+
<img src="vigogne_logo.png" alt="Vigogne" style="width: 40%; min-width: 300px; display: block; margin: auto;">
|
18 |
+
</p>
|
19 |
|
20 |
+
# Vigogne-LoRA-7b: A French Instruct LLaMA Model
|
21 |
|
22 |
+
Vigogne-LoRA-7b is a [LLaMA-7B](https://huggingface.co/decapoda-research/llama-7b-hf) model fine-tuned on the translated [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca) dataset to follow the French 🇫🇷 instructions.
|
23 |
|
24 |
+
For more information, please visit the Github repo: https://github.com/bofenghuang/vigogne
|
25 |
+
|
26 |
+
**Usage and License Notices**: Same as [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca), Vigogne is intended and licensed for research use only. The dataset is CC BY NC 4.0 (allowing only non-commercial use) and models trained using the dataset should not be used outside of research purposes.
|
27 |
|
28 |
## Usage
|
29 |
|
30 |
+
This repo contains only its low-rank adapter. In order to use it, you also need to load the base LLM model and tokenizer.
|
31 |
+
|
32 |
```python
|
|
|
33 |
from peft import PeftModel
|
34 |
+
from transformers import LlamaForCausalLM, LlamaTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
tokenizer = LlamaTokenizer.from_pretrained("decapoda-research/llama-7b-hf")
|
37 |
model = LlamaForCausalLM.from_pretrained(
|
38 |
"decapoda-research/llama-7b-hf",
|
39 |
load_in_8bit=True,
|
|
|
40 |
device_map="auto",
|
41 |
)
|
42 |
+
model = PeftModel.from_pretrained(model, "bofenghuang/vigogne-lora-7b")
|
43 |
+
```
|
|
|
|
|
|
|
44 |
|
45 |
+
You can infer with this model using the following Google Colab Notebook.
|
46 |
|
47 |
+
<a href="https://colab.research.google.com/github/bofenghuang/vigogne/blob/main/infer.ipynb" target="_blank"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
## Limitations
|
|
|
|
|
|
|
50 |
|
51 |
+
Vigogne is still under development, and there are many limitations that have to be addressed. Please note that it is possible that the model generates harmful or biased content, incorrect information or generally unhelpful answers.
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
## Next Steps
|
54 |
|
|
|
55 |
- Add output examples
|
|
vigogne_logo.png
ADDED