Views
No views yet
qingy2024/GRMR-2B-Instruct using optimum-intel
via the export space.pip install optimum[openvino]1from transformers import AutoTokenizer, AutoConfig, pipeline
2from optimum.intel.openvino import OVModelForSeq2SeqLM
3import time
4
5mode_id = "santhosh/GRMR-2B-Instruct-openvino"
6model = OVModelForSeq2SeqLM.from_pretrained(
7 model_id,
8 config=AutoConfig.from_pretrained(model_id),
9 use_cache=True,
10)
11tokenizer = AutoTokenizer.from_pretrained(model_id)
12
13# Create a pipeline
14pipe = pipeline(
15 "text2text-generation",
16 model=model,
17 tokenizer=tokenizer,
18 truncation=True,
19 max_length=256,
20)
21
22texts = [
23 "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.",
24 "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",
25 "He come after the event.",
26 "When I grew up, I start to understand what he said is quite right",
27 "Write this more formally: omg! i love that song im listening to right now",
28 "Improve the grammaticality: As the number of people grows, the need of habitable environment is unquestionably essential.",
29]
30start_time = time.time()
31for result in pipe(texts):
32 print(result)
33end_time = time.time()
34duration = end_time - start_time
35print(f"Correction completed in {duration:.2f} seconds.")