Translation
PEFT
Safetensors
English
Italian
French
llama
bhuvneshsaini commited on
Commit
f3b3e60
1 Parent(s): 3463f91

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -4
README.md CHANGED
@@ -1,11 +1,82 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
4
 
5
  ### Model Description
6
 
7
- - **Developed by:** Bhuvnesh Siani
8
- - **Language(s) (NLP):** Python
9
- - **License:** [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
11
 
 
 
1
  ---
2
+ library_name: peft
3
+ license: mit
4
+ language:
5
+ - en
6
+ - it
7
+ - fr
8
+ datasets:
9
+ - kaitchup/opus-Italian-to-English
10
+ - kaitchup/opus-French-to-English
11
+ tags:
12
+ - translation
13
  ---
14
+ # Model Card for Model ID
15
+
16
+ This is an adapter for Meta's Llama 2 7B fine-tuned for translating Italian text into English.
17
+ ## Model Details
18
 
19
  ### Model Description
20
 
21
+ <!-- Provide a longer summary of what this model is. -->
22
+
23
+
24
+
25
+ - **Developed by:** Bhuvnesh Saini
26
+ - **Model type:** LoRA Adapter for Llama 2 7B
27
+ - **Language(s) (NLP):** French, Italian, English
28
+ - **License:** MIT license
29
+
30
+
31
+
32
+ ## Uses
33
+
34
+ This adapter must be loaded on top of Llama 2 7B. It has been fine-tuned with QLoRA. For optimal results, the base model must be loaded with the exact same configuration used during fine-tuning.
35
+ You can use the following code to load the model:
36
+ ```
37
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
38
+ import torch
39
+ from peft import PeftModel
40
+
41
+ base_model = "meta-llama/Llama-2-7b-hf"
42
+ compute_dtype = getattr(torch, "float16")
43
+ bnb_config = BitsAndBytesConfig(
44
+ load_in_4bit=True,
45
+ bnb_4bit_quant_type="nf4",
46
+ bnb_4bit_compute_dtype=compute_dtype,
47
+ bnb_4bit_use_double_quant=True,
48
+ )
49
+ model = AutoModelForCausalLM.from_pretrained(
50
+ original_model_directory, device_map={"": 0}, quantization_config=bnb_config
51
+ )
52
+ tokenizer = AutoTokenizer.from_pretrained(base_model, use_fast=True)
53
+ model = PeftModel.from_pretrained(model, "kaitchup/Llama-2-7b-mt-Italian-to-English")
54
+ ```
55
+
56
+ Then, run the model as follows:
57
+
58
+ ```
59
+ my_text = "" #put your text to translate here
60
+
61
+ prompt = my_text+" ###>"
62
+
63
+ tokenized_input = tokenizer(prompt, return_tensors="pt")
64
+ input_ids = tokenized_input["input_ids"].cuda()
65
+
66
+ generation_output = model.generate(
67
+ input_ids=input_ids,
68
+ num_beams=10,
69
+ return_dict_in_generate=True,
70
+ output_scores=True,
71
+ max_new_tokens=130
72
+
73
+ )
74
+ for seq in generation_output.sequences:
75
+ output = tokenizer.decode(seq, skip_special_tokens=True)
76
+ print(output.split("###>")[1].strip())
77
+ ```
78
+
79
 
80
+ ## Model Card Contact
81
 
82
+ [The Kaitchup](https://kaitchup.substack.com/)