Views
No views yet
flan-t5-small model for generating short titles from chats.1from transformers import T5ForConditionalGeneration, T5Tokenizer
2
3model = T5ForConditionalGeneration.from_pretrained("dafilab/chat-title-generator")
4tokenizer = T5Tokenizer.from_pretrained("dafilab/chat-title-generator", legacy=False)
5
6def generate_chat_title(text):
7 input_text = "short title: " + text
8 inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=512)
9 outputs = model.generate(
10 input_ids=inputs.input_ids,
11 max_length=64,
12 num_beams=4,
13 early_stopping=True,
14 pad_token_id=tokenizer.pad_token_id,
15 eos_token_id=tokenizer.eos_token_id
16 )
17 return tokenizer.decode(outputs[0], skip_special_tokens=True)
18
19text = """How can I access the GPU of my other computer remotely for ML training?
20To access your other computer's GPU remotely for machine learning (ML) training,
21you need to set up remote access to the machine and ensure that it can properly leverage the GPU for computations.
22There are several ways to do this, depending on your operating system and the tools you prefer to use."""
23print(generate_chat_title(text))
24Remote Access for Machine Learning