<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Debashis Ghosh on Medium]]></title>
        <description><![CDATA[Stories by Debashis Ghosh on Medium]]></description>
        <link>https://medium.com/@debashisghosh_84865?source=rss-fe6516912dae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*aVFdnfJguQ-VHBM5.</url>
            <title>Stories by Debashis Ghosh on Medium</title>
            <link>https://medium.com/@debashisghosh_84865?source=rss-fe6516912dae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:18:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@debashisghosh_84865/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Small Models Are the Future of Agentic AI: A Pure PyTorch GRPO Implementation]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@debashisghosh_84865/small-models-are-the-future-of-agentic-ai-a-pure-pytorch-grpo-implementation-1766225f4c11?source=rss-fe6516912dae------2"><img src="https://cdn-images-1.medium.com/max/1979/1*nljwoBN4xGxWX6AGjHRn_w.png" width="1979"></a></p><p class="medium-feed-snippet">How I Trained a 1B Parameter Model to Achieve 88% Accuracy on Tool Selection&#x200A;&#x2014;&#x200A;And Why It Matters for Production AI Systems</p><p class="medium-feed-link"><a href="https://medium.com/@debashisghosh_84865/small-models-are-the-future-of-agentic-ai-a-pure-pytorch-grpo-implementation-1766225f4c11?source=rss-fe6516912dae------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@debashisghosh_84865/small-models-are-the-future-of-agentic-ai-a-pure-pytorch-grpo-implementation-1766225f4c11?source=rss-fe6516912dae------2</link>
            <guid isPermaLink="false">https://medium.com/p/1766225f4c11</guid>
            <category><![CDATA[small-language-model]]></category>
            <category><![CDATA[grpo]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Debashis Ghosh]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 18:12:01 GMT</pubDate>
            <atom:updated>2026-01-07T18:12:01.090Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building an AI Paper Reviewer with LangGraph and ML Calibration]]></title>
            <link>https://medium.com/@debashisghosh_84865/building-an-ai-paper-reviewer-with-langgraph-and-ml-calibration-8d0d46edcc1f?source=rss-fe6516912dae------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d0d46edcc1f</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mach]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Debashis Ghosh]]></dc:creator>
            <pubDate>Sun, 30 Nov 2025 21:41:53 GMT</pubDate>
            <atom:updated>2025-11-30T21:41:53.409Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Building an AI Paper Reviewer with LangGraph and ML Calibration</strong></p><p><em>A technical walkthrough of combining multi-agent orchestration with regression-based scoring</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*0y9-QKYl9ChRr7quymHEUg.png" /><figcaption>Architecture of the Paper Reviewer Agentic Directed Graph</figcaption></figure><p><strong>If you’ve ever submitted a paper to a top ML conference, you know the wait — 3 to 6 months of silence before hearing anything back. I’ve watched colleagues go through this cycle repeatedly: submit, wait, get sparse feedback, revise, repeat.</strong></p><p>It made me wonder: <strong>What if AI could provide instant, calibrated feedback before submission?</strong></p><p>So I built something: an agentic paper reviewer that doesn’t just critique — it predicts how human reviewers would actually score your work. Not just another LLM wrapper, but a full multi-agent system using <strong>LangGraph</strong> with ML-grounded scoring. The idea is not to replace human judgment, but to give researchers instant, structured feedback with scores calibrated on 46,748 real ICLR reviews.</p><p>The result: <strong>Spearman ρ = 0.74</strong> correlation with human reviewers — meaning when the AI ranks papers, humans agree ~74% of the time.</p><h3>Solution:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXyfi6dpzaFQVFhXUBN0jA.png" /><figcaption>Combination of Agentic+Regression Score generates Human Aligned Score and Feedback</figcaption></figure><h3>Why I choose LangGraph?</h3><ul><li>Graph-based execution — Non-linear flows, loops, branches</li><li>Typed state— Pydantic models, compile-time safety</li><li>Conditional routing— Dynamic paths based on runtime results</li><li>Checkpointing— Resume from failures</li><li>Streaming — Real-time progress updates</li><li>Easy to implement</li></ul><h3>Main Nodes of the Graph</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ncxn-6EziQL8VjS9aRiKrA.png" /><figcaption>Nodes Connectivity in details</figcaption></figure><p>Let me walk through the detail implementation of each node with minute code level details.</p><ol><li>Node 1: Convert PDF to structured text preserving tables, equations, and sections.</li></ol><p><strong>Key insight:</strong> PyMuPDF’s extract texts and create Mrakdown format which preseves the structure of the paper and also easier for LLM to apprehend.</p><pre><br>async def pdf_to_markdown_node(state: ReviewerState) -&gt; dict:<br>    &quot;&quot;&quot;Convert PDF to Markdown using document extraction.&quot;&quot;&quot;<br>    print(&quot;📄 Converting PDF to Markdown...&quot;)<br>    <br>    try:<br>        <br>        pdf_path = state[&quot;paper_pdf_path&quot;]<br>        <br>        # Check if it&#39;s already markdown content (for testing)<br>        if pdf_path.endswith(&quot;.md&quot;) or not os.path.exists(pdf_path):<br>            # Assume it&#39;s already markdown or use provided content<br>            if &quot;paper_markdown&quot; in state and state[&quot;paper_markdown&quot;]:<br>                return {&quot;paper_markdown&quot;: state[&quot;paper_markdown&quot;], &quot;current_stage&quot;: &quot;metadata_extraction&quot;}<br>        <br>        # Try to extract<br>        try:<br>            import fitz  # PyMuPDF<br>            doc = fitz.open(pdf_path)<br>            markdown_content = &quot;&quot;<br>            for page in doc:<br>                markdown_content += page.get_text(&quot;text&quot;) + &quot;\n\n&quot;<br>            doc.close()<br>        except ImportError:<br>            # Fallback: read as text if possible<br>            with open(pdf_path, &#39;r&#39;, encoding=&#39;utf-8&#39;, errors=&#39;ignore&#39;) as f:<br>                markdown_content = f.read()<br>        <br>        return {<br>            &quot;paper_markdown&quot;: markdown_content,<br>            &quot;current_stage&quot;: &quot;metadata_extraction&quot;<br>        }<br>    <br>    except Exception as e:<br>        return {<br>            &quot;errors&quot;: [f&quot;PDF conversion failed: {str(e)}&quot;],<br>            &quot;current_stage&quot;: &quot;failed&quot;<br>        }</pre><p><strong>Why it matters: </strong>Structured markdown helps the LLM understand the paper structure.</p><p>2. Node 2: Metadata Extraction</p><p><strong>Purpose: </strong>Extract title, authors, abstract, keywords.</p><p><strong>Key insight: </strong>Use LangChain’s with_structured_output() for guaranteed schema compliance.</p><pre>async def metadata_extraction_node(state: ReviewerState) -&gt; dict:<br>    llm = get_llm()<br>    content = state[&quot;paper_markdown&quot;][:15000]  # Truncate for context window<br>    <br>    prompt = METADATA_EXTRACTION_PROMPT.format(paper_content=content)<br>    response = await llm.ainvoke([HumanMessage(content=prompt)])<br>    <br>    # Parse JSON from response<br>    json_match = re.search(r&#39;\{[\s\S]*\}&#39;, response.content)<br>    metadata_dict = json.loads(json_match.group())<br>    metadata = PaperMetadata(**metadata_dict)  # Pydantic validation<br>    <br>    if not metadata.is_academic_paper:<br>        return {&quot;validation_passed&quot;: False, &quot;errors&quot;: [&quot;Not an academic paper&quot;]}<br>    <br>    return {<br>        &quot;paper_metadata&quot;: metadata,<br>        &quot;validation_passed&quot;: True,<br>        &quot;current_stage&quot;: &quot;search_query_generation&quot;<br>    }</pre><p><strong>Why it matters: </strong>Structured output eliminates parsing issues— you get a Pydantic object.</p><p>3. Node 3: Search Query Generation</p><p><strong>Purpose: </strong>Generate multi-specificity queries(6–8) for finding related work.</p><p><strong>Key insight:</strong> Generate queries at different specificity levels(high/medium/low) and perspectives (baseline/method/problem/benchmark) to maximize relevant paper discovery.</p><pre>async def search_query_generation_node(state: ReviewerState) -&gt; dict:<br>    llm = get_llm()<br>    metadata = state[&quot;paper_metadata&quot;]<br>    <br>    prompt = SEARCH_QUERY_GENERATION_PROMPT.format(<br>        title=metadata.title,<br>        abstract=metadata.abstract<br>    )<br>    <br>    response = await llm.ainvoke([HumanMessage(content=prompt)])<br>    <br>    # Parse JSON response<br>    json_match = re.search(r&#39;\{[\s\S]*\}&#39;, response.content)<br>    queries_data = json.loads(json_match.group())<br>    queries = queries_data.get(&quot;queries&quot;, [])<br>    <br>    return {&quot;search_queries&quot;: queries, &quot;current_stage&quot;: &quot;web_search&quot;}</pre><pre>SEARCH_QUERY_GENERATION_PROMPT = &quot;&quot;&quot;You are an expert research assistant helping to find related work for a paper review.<br><br>Paper Title: {title}<br>Abstract: {abstract}<br>Keywords: {keywords}<br><br>Generate 6-8 search queries to find relevant prior work on arXiv. Include queries at different specificity levels:<br><br>1. HIGH SPECIFICITY (2-3 queries): Very specific to the exact method/approach<br>2. MEDIUM SPECIFICITY (2-3 queries): Related techniques and benchmarks<br>3. LOW SPECIFICITY (2-3 queries): Broader problem domain and applications<br><br>For each query, also specify the PERSPECTIVE:<br>- &quot;baseline&quot;: Find papers that could be baselines/comparisons<br>- &quot;method&quot;: Find papers with similar methods/techniques<br>- &quot;problem&quot;: Find papers addressing the same problem<br>- &quot;benchmark&quot;: Find relevant benchmarks/datasets<br><br>Respond in JSON format:<br>{{<br>    &quot;queries&quot;: [<br>        {{&quot;query&quot;: &quot;...&quot;, &quot;specificity&quot;: &quot;high/medium/low&quot;, &quot;perspective&quot;: &quot;baseline/method/problem/benchmark&quot;}},<br>        ...<br>    ]<br>}}</pre><p><strong>Why it matters: </strong>Multiple query types increase recall without sacrificing precision.</p><p>4. Node 4: Web Search (arXiv)</p><p><strong>Purpose:</strong> Search arXiv for candidate related papers.</p><p><strong>Key insight:</strong> Use arXiv’s REST API directly with proper XML parsing and rate limiting.</p><pre>async def web_search_node(state: ReviewerState) -&gt; dict:<br>    import urllib.request<br>    import xml.etree.ElementTree as ET<br>    <br>    all_results = []<br>    <br>    for query_info in state[&quot;search_queries&quot;][:5]:  # Limit queries<br>        query = query_info[&quot;query&quot;]<br>        <br>        # arXiv API<br>        url = f&quot;http://export.arxiv.org/api/query?search_query=all:{query}&amp;max_results=5&quot;<br>        <br>        with urllib.request.urlopen(url, timeout=10) as response:<br>            xml_data = response.read().decode(&#39;utf-8&#39;)<br>        <br>        # Parse XML<br>        root = ET.fromstring(xml_data)<br>        ns = {&#39;atom&#39;: &#39;http://www.w3.org/2005/Atom&#39;}<br>        <br>        for entry in root.findall(&#39;atom:entry&#39;, ns):<br>            all_results.append({<br>                &quot;arxiv_id&quot;: entry.find(&#39;atom:id&#39;, ns).text.split(&#39;/&#39;)[-1],<br>                &quot;title&quot;: entry.find(&#39;atom:title&#39;, ns).text.strip(),<br>                &quot;abstract&quot;: entry.find(&#39;atom:summary&#39;, ns).text.strip(),<br>                &quot;authors&quot;: [a.find(&#39;atom:name&#39;, ns).text for a in entry.findall(&#39;atom:author&#39;, ns)]<br>            })<br>        <br>        await asyncio.sleep(0.5)  # Rate limiting<br>    <br>    # Deduplicate by arxiv_id<br>    unique_results = {r[&quot;arxiv_id&quot;]: r for r in all_results}.values()<br>    return {&quot;search_results&quot;: list(unique_results)}</pre><p><strong>Why it matters:</strong> Direct API access is more reliable than web scraping, and deduplication prevents redundant evaluations.</p><p>5. Node 5: Relevance Evaluation</p><p><strong>Purpose:</strong> Score each candidate’s relevance to the paper under review.</p><p><strong>Key insight:</strong> Evaluate each paper individually with LLM, parse structured scores, sort and select top candidates.</p><pre>async def relevance_evaluation_node(state: ReviewerState) -&gt; dict:<br>    llm = get_llm()<br>    metadata = state[&quot;paper_metadata&quot;]<br>    related_works = []<br>    <br>    for result in state[&quot;search_results&quot;][:10]:  # Top 10 candidates<br>        prompt = RELEVANCE_EVALUATION_PROMPT.format(<br>            paper_title=metadata.title,<br>            paper_abstract=metadata.abstract,<br>            candidate_title=result[&quot;title&quot;],<br>            candidate_abstract=result[&quot;abstract&quot;]<br>        )<br>        <br>        response = await llm.ainvoke([HumanMessage(content=prompt)])<br>        <br>        # Parse relevance score (0.0-1.0) from JSON response<br>        json_match = re.search(r&#39;\{[\s\S]*\}&#39;, response.content)<br>        eval_data = json.loads(json_match.group())<br>        <br>        related_work = RelatedWork(<br>            arxiv_id=result[&quot;arxiv_id&quot;],<br>            title=result[&quot;title&quot;],<br>            authors=result[&quot;authors&quot;],<br>            abstract=result[&quot;abstract&quot;],<br>            relevance_score=eval_data.get(&quot;relevance_score&quot;, 0.5)<br>        )<br>        related_works.append(related_work)<br>    <br>    # Sort by relevance, select top 7<br>    related_works.sort(key=lambda x: x.relevance_score, reverse=True)<br>    return {&quot;selected_related_works&quot;: related_works[:7]}</pre><pre>RELEVANCE_EVALUATION_PROMPT = &quot;&quot;&quot;You are evaluating the relevance of a potential related work for a paper review.<br><br>Paper being reviewed:<br>Title: {paper_title}<br>Abstract: {paper_abstract}<br><br>Candidate related work:<br>Title: {candidate_title}<br>Abstract: {candidate_abstract}<br><br>Rate the relevance from 0.0 to 1.0 and decide the summarization approach:<br>- If relevance &gt;= 0.7: Consider &quot;detailed&quot; summary (requires downloading full paper)<br>- If relevance &gt;= 0.4: Use &quot;abstract&quot; summary (use existing abstract)<br>- If relevance &lt; 0.4: May be excluded<br><br>If detailed summary is needed, specify focus areas (what aspects to emphasize).<br><br>Respond in JSON format:<br>{{<br>    &quot;relevance_score&quot;: 0.0-1.0,<br>    &quot;summary_type&quot;: &quot;abstract&quot; or &quot;detailed&quot;,<br>    &quot;focus_areas&quot;: [&quot;...&quot;, &quot;...&quot;],<br>    &quot;reasoning&quot;: &quot;...&quot;<br>}}<br>&quot;&quot;&quot;</pre><p><strong>Why it matters:</strong> LLM-based relevance scoring captures semantic similarity better than keyword matching.</p><p>6. Node 6: Reflection (The Critical Decision Point)</p><p><strong>Purpose:</strong> Check progress and decide whether to continue or replan.</p><p><strong>This is the heart of agentic behavior.</strong> The system evaluates its own progress:</p><pre>async def reflection_node(state: ReviewerState) -&gt; dict:<br>    iteration = state.get(&quot;iteration_count&quot;, 0) + 1<br>    needs_replanning = False<br>    <br>    # Check for issues requiring replanning<br>    if not state.get(&quot;search_results&quot;):<br>        needs_replanning = True<br>        print(&quot;  No search results - may need broader queries&quot;)<br>    <br>    if len(state.get(&quot;selected_related_works&quot;, [])) &lt; 3:<br>        needs_replanning = True<br>        print(&quot;  Few related works - may need additional searches&quot;)<br>    <br>    return {<br>        &quot;iteration_count&quot;: iteration,<br>        &quot;needs_replanning&quot;: needs_replanning<br>    }<br><br>def route_after_reflection(state: ReviewerState) -&gt; str:<br>    &quot;&quot;&quot;Conditional routing based on reflection.&quot;&quot;&quot;<br>    if state.get(&quot;needs_replanning&quot;) and state.get(&quot;iteration_count&quot;, 0) &lt; 3:<br>        return &quot;search_query_generation&quot;  # Loop back<br>    return &quot;continue&quot;  # Move forward</pre><p><strong>Why it matters:</strong> Self-correction catches failures that single-pass approaches miss. If initial queries are too narrow, the agent automatically retries with broader terms.</p><p>7. Node 7: Summarization</p><p><strong>Purpose:</strong> Create focused summaries of selected related papers.</p><p><strong>Key insight:</strong> Generate summaries that highlight relevance to the paper being reviewed, focusing on specific areas identified during relevance evaluation.</p><pre>async def summarization_node(state: ReviewerState) -&gt; dict:<br>    llm = get_llm()<br>    metadata = state[&quot;paper_metadata&quot;]<br>    updated_works = []<br>    <br>    for work in state[&quot;selected_related_works&quot;]:<br>        if work.summary_type == &quot;detailed&quot; and work.focus_areas:<br>            prompt = DETAILED_SUMMARY_PROMPT.format(<br>                paper_content=f&quot;Title: {work.title}\n\nAbstract: {work.abstract}&quot;,<br>                focus_areas=&quot;, &quot;.join(work.focus_areas),<br>                review_paper_title=metadata.title<br>            )<br>            <br>            response = await llm.ainvoke([HumanMessage(content=prompt)])<br>            work.detailed_summary = response.content<br>        <br>        updated_works.append(work)<br>    <br>    return {<br>        &quot;selected_related_works&quot;: updated_works,<br>        &quot;current_stage&quot;: &quot;review_generation&quot;<br>    }</pre><pre>DETAILED_SUMMARY_PROMPT = &quot;&quot;&quot;You are creating a focused summary of a research paper for use in a review.<br><br>Paper to summarize:<br>{paper_content}<br><br>Focus areas to emphasize:<br>{focus_areas}<br><br>Context - this summary will be used to review another paper titled:<br>&quot;{review_paper_title}&quot;<br><br>Create a detailed summary (300-500 words) that:<br>1. Captures the main contributions<br>2. Emphasizes the specified focus areas<br>3. Notes methodology and key results<br>4. Highlights aspects relevant to the paper being reviewed<br><br>Summary:<br>&quot;&quot;&quot;</pre><p><strong>Why it matters:</strong> Context-aware summaries highlighting specific aspects are more useful than generic abstracts for generating targeted reviews.</p><p>8. Node 8: Review Generation</p><p><strong>Purpose:</strong> Generate the complete peer review with all standard sections.</p><p><strong>Key insight:</strong> Provide related work summaries as context so the LLM can identify missing citations and position the paper accurately.</p><pre>async def review_generation_node(state: ReviewerState) -&gt; dict:<br>    llm = get_llm(temperature=0.4)  # Slightly creative<br>    <br>    # Format related work for context<br>    related_summaries = []<br>    for i, work in enumerate(state[&quot;selected_related_works&quot;], 1):<br>        summary = work.detailed_summary or work.abstract<br>        related_summaries.append(<br>            f&quot;[{i}] {work.title} (arXiv:{work.arxiv_id})\n&quot;<br>            f&quot;Authors: {&#39;, &#39;.join(work.authors[:3])}\n&quot;<br>            f&quot;Relevance: {work.relevance_score:.2f}\n&quot;<br>            f&quot;Summary: {summary[:500]}...&quot;<br>        )<br>    <br>    related_work_text = &quot;\n\n&quot;.join(related_summaries)<br>    paper_content = state[&quot;paper_markdown&quot;][:20000]  # Context window limit<br>    <br>    prompt = REVIEW_GENERATION_PROMPT.format(<br>        paper_content=paper_content,<br>        related_work_summaries=related_work_text,<br>        target_venue=state.get(&quot;target_venue&quot;, &quot;General ML/AI venue&quot;)<br>    )<br>    <br>    response = await llm.ainvoke([HumanMessage(content=prompt)])<br>    return {&quot;full_review&quot;: response.content}</pre><pre>REVIEW_GENERATION_PROMPT = &quot;&quot;&quot;You are an expert peer reviewer providing constructive feedback on a research paper.<br><br>=== PAPER BEING REVIEWED ===<br>{paper_content}<br><br>=== RELATED WORK CONTEXT ===<br>{related_work_summaries}<br><br>=== TARGET VENUE ===<br>{target_venue}<br><br>Generate a comprehensive peer review following this structure:<br><br>## Summary<br>Brief summary of the paper&#39;s main contributions and approach.<br><br>## Strengths<br>- List key strengths with specific examples from the paper<br><br>## Weaknesses<br>- List weaknesses with constructive suggestions for improvement<br><br>## Detailed Comments<br>Provide specific, actionable feedback organized by section.<br><br>## Questions for Authors<br>List clarifying questions that would help improve the paper.<br><br>## Missing References<br>Based on the related work, note any important missing citations.<br><br>## Minor Issues<br>Grammar, formatting, clarity issues.<br><br>## Recommendation<br>Overall assessment and recommendation.<br><br>Provide your review:<br>&quot;&quot;&quot;</pre><p><strong>Why it matters:</strong> Providing related work context enables the LLM to make specific comparisons and identify genuinely missing references.</p><p>9. Node 9: Dimensional Scoring (ML Calibration)</p><p><strong>Purpose:</strong> Score on standard dimensions and compute calibrated final score.</p><p><strong>This is where ML meets agents.</strong> The LLM scores each dimension on OpenReview scales, then learned regression weights produce the final score. This is where the value generated from the regression model(regression coefficients) will come into picture. This is another important aspect of grounding. From ICLR 2025 review I got 4 scoring dimension values.</p><pre># Regression coefficients trained on 46,748 ICLR 2025 reviews<br>INTERCEPT = -0.3057<br>COEF_SOUNDNESS = 0.7134       # 32.5% normalized weight<br>COEF_PRESENTATION = 0.4242    # 19.3% normalized weight<br>COEF_CONTRIBUTION = 1.0588    # 48.2% normalized weight<br><br>async def dimensional_scoring_node(state: ReviewerState) -&gt; dict:<br>    llm = get_llm(temperature=0.2)  # Low temp for consistency<br>    <br>    prompt = DIMENSIONAL_SCORING_PROMPT.format(<br>        paper_content=state[&quot;paper_markdown&quot;][:15000],<br>        review_content=state[&quot;full_review&quot;]<br>    )<br>    <br>    response = await llm.ainvoke([HumanMessage(content=prompt)])<br>    <br>    # Parse dimension scores from JSON<br>    json_match = re.search(r&#39;\{[\s\S]*\}&#39;, response.content)<br>    scores_data = json.loads(json_match.group())<br>    dimensions = [ReviewDimension(**dim) for dim in scores_data[&quot;dimensions&quot;]]<br>    <br>    # Extract scores (already on 1-4 scale from LLM)<br>    scores = {d.name: d.score for d in dimensions}<br>    soundness = scores.get(&quot;Soundness&quot;, 2.5)<br>    presentation = scores.get(&quot;Presentation&quot;, 2.5)<br>    contribution = scores.get(&quot;Contribution&quot;, 2.5)<br>    <br>    # Apply regression formula<br>    final_score = (<br>        INTERCEPT +<br>        COEF_SOUNDNESS * soundness +<br>        COEF_PRESENTATION * presentation +<br>        COEF_CONTRIBUTION * contribution<br>    )<br>    <br>    # Clamp to valid range (1-10)<br>    final_score = max(1.0, min(10.0, final_score))<br>    <br>    print(f&quot;  📐 Score: {INTERCEPT:.2f} + {COEF_SOUNDNESS}×{soundness:.0f} + &quot;<br>          f&quot;{COEF_PRESENTATION}×{presentation:.0f} + {COEF_CONTRIBUTION}×{contribution:.0f} &quot;<br>          f&quot;= {final_score:.2f}&quot;)<br>    <br>    return {&quot;dimension_scores&quot;: dimensions, &quot;final_score&quot;: final_score}</pre><pre>DIMENSIONAL_SCORING_PROMPT = &quot;&quot;&quot;You are scoring a research paper on 4 core dimensions used by major ML venues (NeurIPS, ICLR, ICML).<br><br>=== PAPER ===<br>{paper_content}<br><br>=== YOUR REVIEW ===<br>{review_content}<br><br>Score each dimension using the EXACT scales used by OpenReview:<br><br>1. **Soundness** (1-4 scale: Technical Quality)<br>   - Are the claims well-supported by theoretical analysis or empirical evidence?<br>   - Is the methodology rigorous and appropriate?<br>   - Are the experiments well-designed with proper baselines and ablations?<br>   Scale:<br>     1 = Poor: Major technical flaws<br>     2 = Fair: Some concerns about correctness<br>     3 = Good: Technically sound with minor issues<br>     4 = Excellent: Technically excellent, no concerns<br><br>2. **Presentation** (1-4 scale: Clarity &amp; Organization)<br>   - Is the paper well-written and easy to follow?<br>   - Are figures, tables, and equations clear and informative?<br>   - Is the paper well-organized?<br>   Scale:<br>     1 = Poor: Hard to follow, poorly written<br>     2 = Fair: Some clarity issues<br>     3 = Good: Clear with minor issues<br>     4 = Excellent: Exceptionally clear and well-organized<br><br>3. **Contribution** (1-4 scale: Significance &amp; Novelty)<br>   - How significant is this work to the field?<br>   - Does it provide new insights, methods, or results?<br>   - How does it advance the state of the art?<br>   Scale:<br>     1 = Poor: Little to no contribution<br>     2 = Fair: Incremental or limited contribution<br>     3 = Good: Solid contribution<br>     4 = Excellent: Groundbreaking contribution<br><br>4. **Confidence** (1-5 scale: Your Assessment Certainty)<br>   - How confident are you in your evaluation?<br>   - How familiar are you with the related work?<br>   Scale:<br>     1 = Low: Educated guess<br>     2 = Somewhat confident<br>     3 = Fairly confident: Familiar with the area<br>     4 = Confident: Checked key claims<br>     5 = Very confident: Absolutely certain, expert in this area<br><br>Respond in JSON format:<br>{{<br>    &quot;dimensions&quot;: [<br>        {{&quot;name&quot;: &quot;Soundness&quot;, &quot;score&quot;: X, &quot;justification&quot;: &quot;...&quot;}},<br>        {{&quot;name&quot;: &quot;Presentation&quot;, &quot;score&quot;: X, &quot;justification&quot;: &quot;...&quot;}},<br>        {{&quot;name&quot;: &quot;Contribution&quot;, &quot;score&quot;: X, &quot;justification&quot;: &quot;...&quot;}},<br>        {{&quot;name&quot;: &quot;Confidence&quot;, &quot;score&quot;: X, &quot;justification&quot;: &quot;...&quot;}}<br>    ]<br>}}<br><br>IMPORTANT: Use the exact scales above (Soundness/Presentation/Contribution: 1-4, Confidence: 1-5).<br>&quot;&quot;&quot;</pre><p><strong>Why it matters:</strong> This calibration step transforms arbitrary LLM scores into predictions grounded in real reviewer behavior from 46,748 actual reviews.</p><h3>The ML Calibration: Deep Dive</h3><h3>Training Data</h3><p>I analyzed <strong>46,748 peer reviews</strong> from ICLR 2025 (OpenReview API):</p><p><strong>Training Data Fields:</strong></p><ul><li><strong>Soundness</strong> (1–4) — Technical correctness</li><li><strong>Presentation</strong> (1–4) — Clarity and organization</li><li><strong>Contribution</strong> (1–4) — Significance and novelty</li><li><strong>Confidence</strong> (1–5) — Reviewer certainty</li><li><strong>Rating</strong> (1–10) — Overall score (target)</li></ul><h3>The Model</h3><p>Simple linear regression — chosen for interpretability:</p><pre>from sklearn.linear_model import LinearRegression<br><br>X = reviews[[&quot;soundness&quot;, &quot;presentation&quot;, &quot;contribution&quot;]]<br>y = reviews[&quot;rating&quot;]<br><br>model = LinearRegression()<br>model.fit(X, y)<br><br>print(f&quot;Coefficients: {model.coef_}&quot;)<br>print(f&quot;Intercept: {model.intercept_}&quot;)</pre><p>Results</p><pre>Coefficients:<br>  Soundness:     0.7134<br>  Presentation:  0.4242<br>  Contribution:  1.0588<br>  <br>Intercept: -0.3057<br><br>Spearman ρ: 0.7382<br>R² Score:   0.5460</pre><p>The Scoring Formula</p><pre>Rating = -0.31 + 0.71×Soundness + 0.42×Presentation + 1.06×Contribution</pre><p><strong>Key insight:</strong> Reviewers weight contribution (novelty) almost <strong>2.5x more</strong> than presentation (clarity).</p><p>This challenges common advice. A groundbreaking idea with mediocre writing often beats a polished incremental paper.</p><p><strong>Putting It All Together</strong></p><p><strong>Graph Construction with 9 designed nodes:</strong></p><pre>from langgraph.graph import StateGraph, START, END<br>from langgraph.checkpoint.memory import MemorySaver<br><br>def create_paper_reviewer_graph():<br>    # Initialize graph with state schema<br>    workflow = StateGraph(ReviewerState)<br>    <br>    # Add all 9 nodes<br>    workflow.add_node(&quot;pdf_to_markdown&quot;, pdf_to_markdown_node)<br>    workflow.add_node(&quot;metadata_extraction&quot;, metadata_extraction_node)<br>    workflow.add_node(&quot;search_query_generation&quot;, search_query_generation_node)<br>    workflow.add_node(&quot;web_search&quot;, web_search_node)<br>    workflow.add_node(&quot;relevance_evaluation&quot;, relevance_evaluation_node)<br>    workflow.add_node(&quot;reflection&quot;, reflection_node)<br>    workflow.add_node(&quot;summarization&quot;, summarization_node)<br>    workflow.add_node(&quot;review_generation&quot;, review_generation_node)<br>    workflow.add_node(&quot;dimensional_scoring&quot;, dimensional_scoring_node)<br>    <br>    # Main flow<br>    workflow.add_edge(START, &quot;pdf_to_markdown&quot;)<br>    workflow.add_edge(&quot;pdf_to_markdown&quot;, &quot;metadata_extraction&quot;)<br>    <br>    # Conditional: validate it&#39;s an academic paper<br>    workflow.add_conditional_edges(<br>        &quot;metadata_extraction&quot;,<br>        route_after_validation,<br>        {&quot;search_query_generation&quot;: &quot;search_query_generation&quot;, END: END}<br>    )<br>    <br>    workflow.add_edge(&quot;search_query_generation&quot;, &quot;web_search&quot;)<br>    workflow.add_edge(&quot;web_search&quot;, &quot;relevance_evaluation&quot;)<br>    workflow.add_edge(&quot;relevance_evaluation&quot;, &quot;reflection&quot;)<br>    <br>    # Conditional: reflection decides to replan or continue<br>    workflow.add_conditional_edges(<br>        &quot;reflection&quot;,<br>        route_after_reflection,<br>        {&quot;search_query_generation&quot;: &quot;search_query_generation&quot;, &quot;continue&quot;: &quot;summarization&quot;}<br>    )<br>    <br>    workflow.add_edge(&quot;summarization&quot;, &quot;review_generation&quot;)<br>    workflow.add_edge(&quot;review_generation&quot;, &quot;dimensional_scoring&quot;)<br>    workflow.add_edge(&quot;dimensional_scoring&quot;, END)<br>    <br>    # Compile with checkpointing<br>    memory = MemorySaver()<br>    return workflow.compile(checkpointer=memory)</pre><h4>Key Takeaways</h4><h4>1. Agents Need Grounding</h4><p>Pure LLM outputs drift. Connecting agent reasoning to ML calibration (trained on 46K real reviews) transformed the system from a toy into a tool.</p><h4>2. Reflection Enables Self-Correction</h4><p>The reflection node is simple but powerful. Letting the agent check “do I have enough related work?” and loop back if not catches failures that single-pass approaches miss.</p><h4>3. Structured Outputs Eliminate Parsing</h4><p>Using with_structured_output() with Pydantic models means no regex, no JSON parsing errors — just typed objects.</p><h4>4. Simple Models Can Win</h4><p>Linear regression on 3 dimensions achieves 0.74 correlation. More complex models might squeeze out marginal gains but sacrifice interpretability.</p><p><strong>Limitations:</strong></p><ul><li><strong>Trained on ML papers (ICLR)</strong> — May not generalize to other fields like biology, economics, or humanities</li><li><strong>Only 3 scored dimensions</strong> — Doesn’t capture everything reviewers consider (novelty of experiments, ethical concerns, reproducibility). The rest of the dimensions do not have any value in the ICLR 2025 review dataset. Hence did not consider.</li><li><strong>Inherits biases</strong> — Reflects patterns in historical reviews, including any systematic biases in ICLR reviewing</li><li><strong>Context window limits</strong> — Long papers (&gt;30 pages) get truncated, potentially missing important details</li><li><strong>No figure/table analysis</strong> — Currently processes text only; can’t evaluate visualizations or results tables</li></ul><p><strong>This is not a replacement for human peer review</strong> — it’s a tool for pre-submission self-assessment.</p><h3>Acknowledgments</h3><p>Inspired by research from Andrew Ng, Yixing Jiang, and collaborators at Stanford on AI-assisted peer review. Their work motivates me to implement it.</p><p>The key extension: <strong>grounding the system in 46,748 real ICLR reviews</strong> to learn how humans actually weight different dimensions.</p><h3><strong>Working Demo</strong>:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3vabWW-Aptk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3vabWW-Aptk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3vabWW-Aptk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0168b2ea30dbcf6be61af12994cce32/href">https://medium.com/media/d0168b2ea30dbcf6be61af12994cce32/href</a></iframe><p><strong>**GitHub:** Code will be open-sourced soon — follow for updates!</strong></p><p>If you found this useful, I’d love to hear your thoughts and collaborate. What other research workflows could benefit from agentic + ML fusion?</p><p><strong>Tags:</strong> Artificial Intelligence Machine Learning LangChain LangGraph Agents Python Research NLP</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d0d46edcc1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>