Update README.md
Browse files
README.md
CHANGED
@@ -26,8 +26,39 @@ pip install optimum[openvino]
|
|
26 |
To load your model you can do as follows:
|
27 |
|
28 |
```python
|
29 |
-
from
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
model =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
```
|
|
|
26 |
To load your model you can do as follows:
|
27 |
|
28 |
```python
|
29 |
+
from transformers import AutoTokenizer, AutoConfig, pipeline
|
30 |
+
from optimum.intel.openvino import OVModelForSeq2SeqLM
|
31 |
+
import time
|
32 |
|
33 |
+
mode_id = "santhosh/GRMR-2B-Instruct-openvino"
|
34 |
+
model = OVModelForSeq2SeqLM.from_pretrained(
|
35 |
+
model_id,
|
36 |
+
config=AutoConfig.from_pretrained(model_id),
|
37 |
+
use_cache=True,
|
38 |
+
)
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
40 |
+
|
41 |
+
# Create a pipeline
|
42 |
+
pipe = pipeline(
|
43 |
+
"text2text-generation",
|
44 |
+
model=model,
|
45 |
+
tokenizer=tokenizer,
|
46 |
+
truncation=True,
|
47 |
+
max_length=256,
|
48 |
+
)
|
49 |
+
|
50 |
+
texts = [
|
51 |
+
"Most of the course is about semantic or content of language but there are also interesting topics to be learned from the servicefeatures except statistics in characters in documents.",
|
52 |
+
"At this point, He introduces herself as his native English speaker and goes on to say that if you contine to work on social scnce",
|
53 |
+
"He come after the event.",
|
54 |
+
"When I grew up, I start to understand what he said is quite right",
|
55 |
+
"Write this more formally: omg! i love that song im listening to right now",
|
56 |
+
"Improve the grammaticality: As the number of people grows, the need of habitable environment is unquestionably essential.",
|
57 |
+
]
|
58 |
+
start_time = time.time()
|
59 |
+
for result in pipe(texts):
|
60 |
+
print(result)
|
61 |
+
end_time = time.time()
|
62 |
+
duration = end_time - start_time
|
63 |
+
print(f"Correction completed in {duration:.2f} seconds.")
|
64 |
```
|