Views
No views yet
transformers library, ensure you format your input using the specific tags <PAPER_CONTENT>, <SELECTED_CONTENT>, and <QUESTION>.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# Select the model size: "XtraGPT-1.5B", "XtraGPT-3B", "XtraGPT-7B", or "XtraGPT-14B"
5model_name = "Xtra-Computing/XtraGPT-7B"
6
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForCausalLM.from_pretrained(
9 model_name,
10 torch_dtype=torch.float16,
11 device_map="auto"
12)
13
14# Define the Prompt Template tailored for XtraGPT
15prompt_template = """Act as an expert model for improving articles **PAPER_CONTENT**.
16The output needs to answer the **QUESTION** on **SELECTED_CONTENT** in the input. Avoid adding unnecessary length, unrelated details, overclaims, or vague statements.
17Focus on clear, concise, and evidence-based improvements that align with the overall context of the paper.
18<PAPER_CONTENT>
19{paper_content}
20</PAPER_CONTENT>
21<SELECTED_CONTENT>
22{selected_content}
23</SELECTED_CONTENT>
24<QUESTION>
25{user_question}
26</QUESTION>"""
27
28# Example Data (from the "Attention Is All You Need" paper)
29paper_content = "The dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train."
30selected_content = "The dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration."
31user_question = "help me make it more concise."
32
33# Format the input
34formatted_prompt = prompt_template.format(
35 paper_content=paper_content,
36 selected_content=selected_content,
37 user_question=user_question
38)
39
40messages = [
41 {"role": "user", "content": formatted_prompt}
42]
43
44# Apply chat template
45text = tokenizer.apply_chat_template(
46 messages,
47 tokenize=False,
48 add_generation_prompt=True
49)
50
51model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
52
53# Generate
54generated_ids = model.generate(
55 **model_inputs,
56 max_new_tokens=16384,
57 temperature=0.1
58)
59
60generated_ids = [
61 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
62]
63
64response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
65print(response)XtraGPT-14B with your specific model variant.1python -m vllm.entrypoints.openai.api_server \
2 --port 8088 \
3 --model Xtra-Computing/XtraGPT-14B \
4 --served-model-name xtragpt \
5 --max-model-len 16384 \
6 --gpu-memory-utilization 0.951curl [http://127.0.0.1:8088/v1/chat/completions](http://127.0.0.1:8088/v1/chat/completions) \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "xtragpt",
5 "messages": [
6 {
7 "role": "user",
8 "content": "Please improve the selected content based on the following. Act as an expert model for improving articles **PAPER_CONTENT**.\nThe output needs to answer the **QUESTION** on **SELECTED_CONTENT** in the input. Avoid adding unnecessary length, unrelated details, overclaims, or vague statements.\nFocus on clear, concise, and evidence-based improvements that align with the overall context of the paper.\n<PAPER_CONTENT>\nThe dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train.\n</PAPER_CONTENT>\n<SELECTED_CONTENT>\nThe dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration.\n</SELECTED_CONTENT>\n<QUESTION>\nhelp me make it more concise.\n</QUESTION>"
9 }
10 ],
11 "temperature": 0.1,
12 "max_new_tokens": 16384,
13 "stream": false
14 }'LICENSE file in the repository.@inproceedings{
chen2026xtragpt,
title={XtraGPT: Context-Aware and Controllable Academic Paper Revision via Human-AI Collaboration},
author={Nuo Chen and Andre Lin HuiKai and Jiaying Wu and Junyi Hou and Zining Zhang and Qian Wang and Xidong Wang and Bingsheng He},
booktitle = "Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
year={2026},
note={Available on arXiv:2505.11336}
}