helenai commited on
Commit
b98691f
1 Parent(s): fdb7c0a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -8
README.md CHANGED
@@ -11,15 +11,15 @@ This is the [Salesforce/codegen2-1B](https://huggingface.co/Salesforce/codegen2-
11
 
12
  An example of how to do inference on this model:
13
  ```python
 
14
  from optimum.intel.openvino import OVModelForCausalLM
15
- from transformers import AutoTokenizer, pipeline
16
 
17
- # model_id should be set to either a local directory or a model available on the HuggingFace hub.
18
- model_id = "helenai/Salesforce-codegen2-1B-ov"
19
- tokenizer = AutoTokenizer.from_pretrained(model_id)
20
- model = OVModelForCausalLM.from_pretrained(model_id)
21
- pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
22
- result = pipe("My name is Julien and I like to")
23
- print(result)
24
  ```
25
 
 
11
 
12
  An example of how to do inference on this model:
13
  ```python
14
+ from transformers import AutoTokenizer
15
  from optimum.intel.openvino import OVModelForCausalLM
 
16
 
17
+ tokenizer = AutoTokenizer.from_pretrained("helenai/Salesforce-codegen2-1B-ov")
18
+ model = OVModelForCausalLM.from_pretrained("helenai/Salesforce-codegen2-1B-ov")
19
+
20
+ text = "def hello_world():"
21
+ input_ids = tokenizer(text, return_tensors="pt").input_ids
22
+ generated_ids = model.generate(input_ids, max_length=128)
23
+ print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
24
  ```
25