Views
No views yet
1import transformers
2import torch
3
4model_id = "Systran/Llama-3.1-8B-Instruct-ft-wmt25-classifier"
5
6pipeline = transformers.pipeline(
7 "text-generation",
8 model=model_id,
9 model_kwargs={"torch_dtype": torch.bfloat16},
10 device_map="auto",
11)
12
13messages = [
14 {"role": "system", "content": "You are a language expert."},
15 {
16 "role": "user",
17 "content": "Classify the following English sentence into one of the following categories based on its content and style:\nNews: Factual reporting or informative text typically found in journalism.\nSocial: Informal, conversational, or casual text often used on social media or in personal messages.\nSpeech: Spoken or scripted verbal communication, such as political speeches, interviews, or lectures.\nLiterary: Creative or artistic writing, including fiction, poetry, or other literary works.\n\nSentence: What is hip hop?\n\nYour task: Identify the most appropriate category from the four above. Just respond with the category name: News, Social, Speech, or Literary.",
18 },
19]
20
21outputs = pipeline(
22 messages,
23 max_new_tokens=256,
24)
25print(outputs[0]["generated_text"][-1])
26
27