Paper Reading Assistant
ToolsRAGBeginner
Paper Reading Assistant
Given a doc_id, read the full text in segments and extract methods, data, conclusions, and limitations
Scenario
Users already know a paper doc_id and need to read the full text in segments, extracting key information such as methods, datasets, conclusions, and limitations.
Estimated calls
~5-12 API calls per paper
Tools
contentPipeline
doc_id→ content 循环读取→ 分段拼接全文→ LLM 抽取结构
Input example
Input: doc_id="paper_xxx" Need: read the paper and extract structured notes.
Output example
Structured reading notes: - Methods: ... - Data: ... - Results: ... - Limitations: ... - Source offsets: ...
Agent Prompt example
You are a paper reading assistant. Read the paper segment by segment using content, extract structured notes, and keep source offsets for every extracted point.Implementation steps
Step 1: Set up the environment
Configure token and HTTP client
!pip install httpx anthropic
import os
os.environ["SCIVERSE_API_TOKEN"] = "sv-your-token-here" # 替换为你的真实值
import os
os.environ["ANTHROPIC_API_KEY"] = "sk-ant-..." # 替换为你的真实值
Step 2: Read full text in segments
Call content repeatedly with next_offset until the needed sections are read
import os
import asyncio
import httpx
BASE = "https://api.sciverse.space"
TOKEN = os.environ["SCIVERSE_API_TOKEN"]
HEADERS = {"Authorization": f"Bearer {TOKEN}"}
async def read_full_text(doc_id: str, chunk_size: int = 4000) -> str:
"""\u5faa\u73af\u8bfb\u53d6\u5168\u6587\uff0c\u76f4\u5230 more=false"""
full_text = []
offset = 0
async with httpx.AsyncClient(timeout=30) as client:
while True:
resp = await client.get(
f"{BASE}/content", headers=HEADERS,
params={"doc_id": doc_id, "offset": offset, "limit": chunk_size}
)
resp.raise_for_status()
data = resp.json()
full_text.append(data["text"])
if not data.get("more", False):
break
offset = data["next_offset"]
return "".join(full_text)
# \u5148\u901a\u8fc7 agentic-search \u83b7\u53d6\u771f\u5b9e doc_id
async def find_doc_id(query: str) -> str:
"""Find a real doc_id before reading full text."""
async with httpx.AsyncClient(timeout=30) as client:
resp = await client.post(
f"{BASE}/agentic-search",
headers=HEADERS,
json={"query": query, "top_k": 1},
)
resp.raise_for_status()
hits = (resp.json().get("hits") or [])
if not hits:
raise ValueError(f"No papers found for query: {query}")
return hits[0]["doc_id"]
doc_id = await find_doc_id("AlphaFold2")
text = await read_full_text(doc_id)
print(f"Full text length: {len(text)} chars")
print(f"Preview: {text[:300]}...")
Step 3: Extract structured information with an LLM
Ask an LLM to extract methods, data, conclusions, and limitations with source offsets
from anthropic import Anthropic
client = Anthropic()
def extract_structure(full_text: str) -> str:
"""\u7528 LLM \u62bd\u53d6\u8bba\u6587\u7ed3\u6784\u5316\u4fe1\u606f"""
# \u5982\u679c\u5168\u6587\u592a\u957f\uff0c\u53d6\u524d 15000 \u5b57\u7b26
content = full_text[:15000] if len(full_text) > 15000 else full_text
msg = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=3000,
messages=[{
"role": "user",
"content": f"""\u8bf7\u9605\u8bfb\u4ee5\u4e0b\u8bba\u6587\u5168\u6587\uff0c\u63d0\u53d6\u4ee5\u4e0b\u56db\u4e2a\u65b9\u9762\u7684\u5173\u952e\u4fe1\u606f\uff1a
1. **\u65b9\u6cd5**: \u6838\u5fc3\u6280\u672f\u65b9\u6cd5\u548c\u521b\u65b0\u70b9
2. **\u6570\u636e**: \u4f7f\u7528\u7684\u6570\u636e\u96c6\u3001\u5b9e\u9a8c\u8bbe\u7f6e\u3001\u5173\u952e\u6570\u503c
3. **\u7ed3\u8bba**: \u4e3b\u8981\u53d1\u73b0\u548c\u8d21\u732e
4. **\u5c40\u9650**: \u5df2\u77e5\u5c40\u9650\u548c\u672a\u6765\u5de5\u4f5c\u65b9\u5411
\u8bba\u6587\u5168\u6587:
{content}"""
}]
)
return msg.content[0].text
report = extract_structure(text)
print(report)
Notes
- Read in segments to avoid context overflow.
- Preserve offsets for every extracted note.
- Summarize only after collecting enough source text.
- Separate factual extraction from interpretation.
- Use this as a building block for review and grounding workflows.
FAQ
如何读取长论文?
用 content 按 offset 分段读取,再分段抽取和合并结果。
阅读报告如何保证可追溯?
方法、数据、结论和局限都应绑定原文位置或 quote。
适合哪些阅读任务?
适合快速抽取论文方法、实验设置、数据集、结论和局限。
论文太长怎么办?
应分段总结,再合并成结构化报告,避免一次性塞入模型上下文。
Next steps
Need an API key?
Create one in Console > Tokens.The same API key works for enabled Sciverse, DianShi, and Skills capabilities, with starter quota available according to account permissions.