Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3model_name = "DrDrek/crewai-finetuned-model"
4input_text = "junior software developer"
5torch.device('cuda' if torch.cuda.is_available() else 'cpu')
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 low_cpu_mem_usage=True,
9 return_dict=True,
10 torch_dtype=torch.float16,
11 device_map="auto",
12)
13tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
14input_ids = tokenizer(input_text, return_tensors="pt")
15outputs = model.generate(**input_ids, max_length=128)
16output = tokenizer.decode(outputs[0])
17#print("llm output:",output)
18
19backstory=(output.split("\n\n"))[1].split("\n\n")[0]
20goal=(output.split(backstory)[1].replace("<eos>","")).replace("\n\n","")
21print("backstory:",backstory)
22print("goal:",goal)
23#Output:
24#>>backstory: I am a junior software developer with a passion for building innovative and user-friendly applications. I am currently studying Computer Science at the University of Waterloo, and I am always looking for new challenges and opportunities to grow as a developer.
25#>>goal: I am a strong believer in the power of technology to improve people's lives, and I am dedicated to using my skills to make a positive impact in the world.I am always looking for new ways to learn and grow, and I am excited to see where my journey takes me.