Views
No views yet
1from store.service_management import ServiceManager
2
3service_manager = ServiceManager().get_service("cheapity3")
4
5service.install()
6
7service = service.launch()
8
9input_text = "The mechanical engineering field requires ... "
10
11generated_texts = service.play(input_text, 15) # A list a generated text"Italy, officially the Italian Republic is a country consisting of"15 -- 😃 Yes, you can control the length.1from transformers import AutoTokenizer, AutoModelWithLMHead
2
3tokenizer = AutoTokenizer.from_pretrained("flexudy/cheapity3")
4
5model = AutoModelWithLMHead.from_pretrained("flexudy/cheapity3")
6
7input_text = """The mechanical engineering field requires an understanding of core areas including mechanics, dynamics,
8 thermodynamics, materials science, structural analysis, and
9 electricity. { _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ }""" # 15 words
10
11inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=512)
12
13input_ids = inputs["input_ids"]
14
15attention_mask = inputs["attention_mask"]
16
17outputs = model.generate(
18 input_ids=input_ids,
19 attention_mask=attention_mask,
20 max_length=128,
21 do_sample=True,
22 early_stopping=True,
23 num_return_sequences=4,
24 repetition_penalty=2.5
25)
26
27for i in range(4):
28 print(tokenizer.decode(outputs[i], skip_special_tokens=True, clean_up_tokenization_spaces=True))> Cheapity3 continues with beam search:
... The field of mechanical engineering is a broad field that includes many core areas of engineering.
> Cheapity3 continues with sampling and top_k=50:
... Developing the knowledge base for these core areas will enable engineers to build their capabilities rapidly and efficiently. ...
... The field of mechanics offers a variety and broad range for applications throughout the engineering/technological fields. ...
... Mechanics generally is not understood by students. While they can be employed in the field, mechanical engineering ...
... Introduction to mechanical engineering and core fields including chemical products, materials science, structural analysis, and geomatics ...