DEV Community

shashank ms
shashank ms

Posted on

Using LLMs for Research Purposes

We are going to build a research synthesis agent that ingests a set of academic abstracts and emits a structured analysis: key findings, conflicts, and follow-up questions. This is useful for graduate students, research scientists, and R&D teams who need to compress hours of literature review into minutes. We will run everything against Oxlo.ai using the standard OpenAI SDK.

What you'll need

  • Python 3.10 or newer installed locally.
  • An Oxlo.ai API key from https://portal.oxlo.ai.
  • The OpenAI SDK installed: pip install openai.

Step 1: Initialize the Oxlo.ai client

I keep my API key in an environment variable for safety, but you can paste it directly when testing locally. The base URL points to Oxlo.ai.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

Step 2: Curate the research corpus

Instead of wiring up a live search API, I will use a small list of realistic abstracts on intermittent fasting and metabolic health. This keeps the tutorial fully reproducible.

PAPERS = [
    {
        "title": "Effect of Intermittent Fasting on Cardiometabolic Risk Factors",
        "abstract": "This randomized controlled trial examined 12 weeks of time-restricted eating in adults with obesity. Participants restricted eating to an 8-hour window. Outcomes included weight loss, blood pressure, and fasting glucose. The intervention group showed significant reductions in body weight and systolic blood pressure compared to controls, though LDL cholesterol changes were non-significant."
    },
    {
        "title": "Alternate Day Fasting and Insulin Sensitivity",
        "abstract": "We investigated alternate day fasting in a 6-month trial of prediabetic patients. The fasting group exhibited improved insulin sensitivity and reduced fasting insulin levels. However, adherence dropped to 60 percent by month four, and dropout rates exceeded the continuous calorie restriction arm."
    },
    {
        "title": "Metabolic Effects of Prolonged Nightly Fasting",
        "abstract": "A cross-sectional study of overnight fasting duration and metabolic syndrome markers in 2,000 adults. Longer nightly fasting periods correlated with lower HbA1c and C-reactive protein. No association was found for triglycerides or HDL cholesterol after adjusting for confounders."
    },
    {
        "title": "Intermittent Fasting and Lean Mass Retention",
        "abstract": "This study compared intermittent fasting versus daily calorie restriction during a 24-week weight loss protocol. Both groups lost equivalent total mass, but the fasting group lost significantly more lean body mass. Protein distribution and resistance training were identified as mitigating factors."
    }
]

Step 3: Define the system prompt

The system prompt forces the model into a rigid analyst persona. I want the output to follow the same markdown structure every time so I can parse it or render it downstream.

SYSTEM_PROMPT = """You are a research synthesis assistant. Analyze the provided academic abstracts and produce a structured brief.

Use exactly this format:

## Summary
A 2 to 3 sentence overview of the collective evidence.

## Key Findings
- A bullet list of concrete results. Cite the paper title for each claim.

## Conflicts or Gaps
- A bullet list of contradictory results, methodological weaknesses, or missing data.

## Follow-up Questions
- Three specific questions a researcher should explore next.

Rules:
- Be concise and technical.
- Ground every claim in the provided abstracts.
- Do not introduce outside knowledge."""

Step 4: Build the synthesis function

This function formats the corpus into a single user message and calls Llama 3.3 70B on Oxlo.ai. Because Oxlo.ai charges per request rather than per token, I can stuff the entire corpus into the context window without worrying about input length driving up cost.

def synthesize_research(papers):
    user_message = "Analyze the following research abstracts and produce the structured brief:\n\n"
    for i, paper in enumerate(papers, 1):
        user_message += f"{i}. {paper['title']}\n{paper['abstract']}\n\n"

    response = client.chat.completions.create(
        model="llama-3.3-70b",
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": user_message},
        ],
    )

    return response.choices[0].message.content

Step 5: Execute the pipeline

Running the script invokes the agent and prints the markdown report.

if __name__ == "__main__":
    report = synthesize_research(PAPERS)
    print(report)

Run it

Save the code as research_agent.py and run python research_agent.py. On Oxlo.ai, Llama 3.3 70B starts instantly with no cold starts. The output should look something like this:

## Summary
Across four studies, intermittent fasting demonstrates consistent benefits for weight loss, blood pressure, and insulin sensitivity, though effects on lipid profiles are mixed and adherence remains a practical challenge.

## Key Findings
- Time-restricted eating over 12 weeks significantly reduced body weight and systolic blood pressure ("Effect of Intermittent Fasting on Cardiometabolic Risk Factors").
- Alternate day fasting improved insulin sensitivity and lowered fasting insulin in prediabetic patients ("Alternate Day Fasting and Insulin Sensitivity").
- Longer nightly fasting correlated with lower HbA1c and C-reactive protein in a large cross-sectional sample ("Metabolic Effects of Prolonged Nightly Fasting").
- Intermittent fasting produced equivalent total weight loss to daily calorie restriction but with greater lean mass loss ("Intermittent Fasting and Lean Mass Retention").

## Conflicts or Gaps
- LDL cholesterol and triglyceride outcomes are inconsistent; one trial found non-significant LDL changes, while the cross-sectional study found no triglyceride association.
- Adherence data is sparse; the alternate day fasting arm saw 40 percent non-adherence by month four.
- No study directly compared time-restricted eating versus alternate day fasting head-to-head.

## Follow-up Questions
1. Does protein timing within the fasting window mitigate lean mass loss during intermittent fasting protocols?
2. How do lipid responses vary between time-restricted eating and alternate day fasting in a randomized comparison?
3. What behavioral interventions can sustain adherence beyond month four in alternate day fasting trials?

Wrap-up

You now have a working research synthesis agent that runs on Oxlo.ai. A concrete next step is to wire in the PubMed or arXiv API so the corpus pulls live abstracts rather than hardcoded strings. Another is to add a second pass with deepseek-v3.2 or kimi-k2.6 to convert the markdown brief into BibTeX or a LaTeX literature review section.

Because Oxlo.ai uses flat per-request pricing, you can feed long papers or dozens of abstracts into a single API call without the cost scaling by token count. For workloads like this, that can be significantly cheaper than token-based providers. See https://oxlo.ai/pricing for details.

Top comments (0)