Views
No views yet
transformers library. Below is a straightforward example of how to deploy the shellwork/ChatParts-llama3.1-8b model using transformers.transformers version >= 4.43.0 installed. You can update your installation using:pip install --upgrade transformers1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3import json
4
5# Load the tokenizer and model
6tokenizer = AutoTokenizer.from_pretrained('shellwork/ChatParts-llama3.1-8b', trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 'shellwork/ChatParts-llama3.1-8b',
9 torch_dtype=torch.bfloat16,
10 trust_remote_code=True,
11 device_map='auto'
12)
13
14# Example context from synthetic biology literature
15context = '''
16Synthetic biology enables the design and construction of new biological parts, devices, and systems, or the re-design of existing natural biological systems.
17'''
18
19query = "What is the goal of synthetic biology?"
20
21# Generate the response with fine-grained citations
22result = model.query_longcite(
23 context,
24 query,
25 tokenizer=tokenizer,
26 max_input_length=128000,
27 max_new_tokens=1024
28)
29
30# Display the results
31print("Answer:\n{}\n".format(result['answer']))
32print("Statement with citations:\n{}\n".format(
33 json.dumps(result['statements_with_citations'], indent=2, ensure_ascii=False)
34))
35print("Context (divided into sentences):\n{}\n".format(result['splited_context']))