versae commited on
Commit
1ec0a9c
1 Parent(s): a286db9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -14
README.md CHANGED
@@ -16,7 +16,7 @@ This is a Spanish adapter generated by fine-tuning LLaMA-7B on a [Spanish Alpaca
16
 
17
  ```python
18
  from peft import PeftModel
19
- from transformers import LLaMATokenizer, LLaMAForCausalLM
20
 
21
  base_model = "decapoda-research/llama-7b-hf"
22
  tokenizer = LLaMATokenizer.from_pretrained(base_model)
@@ -31,15 +31,10 @@ model = PeftModel.from_pretrained(model, "bertin-project/bertin-alpaca-lora-7b")
31
  Until `PEFT` is fully supported in Hugginface0s pipelines, for generation we can either consolidate the LoRA weights into the LLaMA model weights, or use the adapter's `generate()` method. Remember that the promtp still needs the English template:
32
 
33
  ```python
34
- from transformers import GenerationConfig
35
-
36
- # Load the model
37
- model = ...
38
-
39
- # Generate prompts from Alpaca template
40
- def generate_prompt(instruction, input=None):
41
  if input:
42
- return f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. # noqa: E501
43
 
44
  ### Instruction:
45
  {instruction}
@@ -50,17 +45,13 @@ def generate_prompt(instruction, input=None):
50
  ### Response:
51
  """
52
  else:
53
- return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request. # noqa: E501
54
 
55
  ### Instruction:
56
  {instruction}
57
 
58
  ### Response:
59
  """
60
-
61
- # Generate responses
62
- def generate(instruction, input=None):
63
- prompt = generate_prompt(instruction, input)
64
  inputs = tokenizer(prompt, return_tensors="pt")
65
  input_ids = inputs["input_ids"].cuda()
66
  generation_output = model.generate(
 
16
 
17
  ```python
18
  from peft import PeftModel
19
+ from transformers import LLaMATokenizer, LLaMAForCausalLM, GenerationConfig
20
 
21
  base_model = "decapoda-research/llama-7b-hf"
22
  tokenizer = LLaMATokenizer.from_pretrained(base_model)
 
31
  Until `PEFT` is fully supported in Hugginface0s pipelines, for generation we can either consolidate the LoRA weights into the LLaMA model weights, or use the adapter's `generate()` method. Remember that the promtp still needs the English template:
32
 
33
  ```python
34
+ # Generate responses
35
+ def generate(instruction, input=None):
 
 
 
 
 
36
  if input:
37
+ prompt = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. # noqa: E501
38
 
39
  ### Instruction:
40
  {instruction}
 
45
  ### Response:
46
  """
47
  else:
48
+ prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request. # noqa: E501
49
 
50
  ### Instruction:
51
  {instruction}
52
 
53
  ### Response:
54
  """
 
 
 
 
55
  inputs = tokenizer(prompt, return_tensors="pt")
56
  input_ids = inputs["input_ids"].cuda()
57
  generation_output = model.generate(