서론
저희는 유도 과정을 확인하고, 방정식을 안전하게 평가하며, 논문 발췌본에서 구조화된 메타데이터를 추출하는 경량의 물리학 연구 비서(physics research assistant)를 구축하고 있습니다. Oxlo.ai는 요청 기반(request-based) 가격 책정을 사용하기 때문에, 토큰 기반 청구 방식이었다면 비용이 증가했을 다중 페이지 LaTeX 프리프린트를 입력해도 비용이 늘지 않습니다.
준비물
Step 1: 클라이언트 부트스트랩(Bootstrap the client)
먼저, 환경이 Oxlo.ai에 접근할 수 있는지 확인하고, 추론 모델(reasoning model)이 기본적인 운동학 문제(kinematics problem)를 해결할 수 있는지 확인합니다. 저는 여기서 deepseek-v3.2를 사용하는데, 이 모델은 수학 및 코딩 작업을 안정적으로 처리하기 때문입니다.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
...
Step 2: 시스템 프롬프트 정의(Define the system prompt)
시스템 프롬프트는 모델을 물리학 추론에 국한시키고, 산술 계산을 환각(hallucinating)하는 대신 로컬 도구로 위임하도록 강제합니다.
SYSTEM_PROMPT = """You are a physics research assistant. Your job is to help analyze problems, check derivations, and suggest experiments.\n\nRules:\n..."
우리는 SymPy를 사용하여 표현식을 안전하게 평가할 것입니다. 또한 LLM이 언제 이를 호출해야 하는지 알 수 있도록 도구 스키마(tool schema)도 노출합니다.
import json
from sympy import sympify, latex, N
...
이 함수는 도구 정의를 첨부하여 대화를 Oxlo.ai로 전송합니다. 모델이 도구 호출을 요청하면, 로컬 핸들러를 실행하고 그 결과를 최종 답변을 위해 다시 보내줍니다.
def run_agent(user_message: str, model: str = "deepseek-v3.2"):
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
...
문헌 검토를 위해서는 구조화된 메타데이터가 필요합니다. 우리는 kimi-k2.6에서 JSON 모드를 사용하여 원시 LaTeX로부터 저자, 핵심 방정식, 주장 및 제안된 실험을 추출합니다.
def extract_paper_metadata(latex_excerpt: str, model: str = "kimi-k2.6"):
prompt = f"""Extract metadata from the following physics paper excerpt.
Return valid JSON with exactly these keys: authors, key_equations, claims, suggested_experiments.
...
실행하기 (Run it)
아래 코드 스니펫이 모든 것을 연결합니다. 에이전트를 통해 유도 과정 검사를 수행한 다음 가짜 발췌문에서 메타데이터를 추출합니다.
if __name__ == "__main__":
query = """Check this derivation:
Starting from F = ma for constant force, integrate acceleration with respect to time.
...
예시 출력:
=== 에이전트 응답 (AGENT RESPONSE) ===
The derivation is correct. Starting from F = ma, constant acceleration a = F/m. Integrating a dt from 0 to t gives v - v0 = (F/m)*t, so v = v0 + (F/m)*t.
For a tabletop experiment, use an air track with a glider of known mass. Apply a constant force via a hanging mass and pulley. Measure velocity at multiple time gates and verify linearity against the predicted slope F/m.
=== 구조화된 메타데이터 (STRUCTURED METADATA) ===
{'authors': ['J. Doe', 'R. Smith'], 'key_equations': ['V(r) = -g^2 e^{-mr}/r'], 'claims': ['A modified Yukawa potential explains anomalous scattering at low energies'], 'suggested_experiments': ['Tabletop laser interferometry to measure the coupling g']}
다음 단계 (Next steps)
이 에이전트를 arXiv RSS 피드에 연결하여 사용자의 세부 분야의 새로운 사전 인쇄본(preprints)을 자동으로 처리하도록 합니다. 더 무거운 사고 사슬 추론(chain-of-thought reasoning)이 필요하면, 클라이언트 코드를 변경하지 않고 Oxlo.ai에서 deepseek-v3.2를 llama-3.3-70b 또는 qwen-3-32b로 교체하십시오.