Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:ThreeSR Awesome Inference Time Scaling Search Papers Function

From Leeroopedia
Page Metadata
Knowledge Sources Awesome-Inference-Time-Scaling
Domains Academic Search, API Integration, Scholarly Literature Discovery
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete tool for querying the Semantic Scholar Academic Graph API to discover papers by keyword, provided by the search_papers() function in fetch_semantic_info.py.

Description

The search_papers() function constructs a search URL against the Semantic Scholar Graph API v1 endpoint, sends an HTTP GET request, and returns a list of paper metadata dictionaries. It requests a specific set of fields (title, authors, venue, year, publicationDate, fieldsOfStudy, url) and sorts results by year. If the API returns a non-200 status code, the function prints an error message and returns an empty list.

The function relies on two module-level constants:

Usage

Import or call this function when:

  • You need to discover papers matching a search query (e.g., "Inference-Time Scaling")
  • You are building or updating a curated paper list
  • You want to retrieve structured metadata for a batch of recent papers from Semantic Scholar

Code Reference

Source Location: fetch_semantic_info.py, lines 22-29

Function Signature:

def search_papers(query: str, limit: int = 5) -> list[dict]

Import Statement:

from fetch_semantic_info import search_papers

Source Code:

def search_papers(query, limit=5):
    """Fetch relevant papers from the Semantic Scholar API"""
    url = f"{BASE_URL}paper/search?query={query}&fields={FIELDS}&limit={limit}&sort=year"
    response = requests.get(url)
    if response.status_code != 200:
        print("Error fetching data from Semantic Scholar API")
        return []
    return response.json().get("data", [])

Dependencies:

  • requests (third-party HTTP library)

API Endpoint:

GET https://api.semanticscholar.org/graph/v1/paper/search?query={query}&fields={fields}&limit={limit}&sort=year

I/O Contract

Inputs:

Parameter Type Default Description
query str (required) The search query string (e.g., a paper topic or title)
limit int 5 Maximum number of paper results to return

Outputs:

Field Type Description
title str The title of the paper
authors list[dict] List of author objects, each containing a name field
venue str The publication venue (journal, conference, or empty string)
year int The publication year
publicationDate str The publication date in YYYY-MM-DD format
fieldsOfStudy list[str] Academic fields the paper belongs to (e.g., "Computer Science")
url str URL to the paper on Semantic Scholar
paperId str Semantic Scholar unique paper identifier (always included by default)

The function returns a list[dict]. Each dictionary contains the fields listed above. On API failure, an empty list [] is returned.

Usage Examples

Example 1: Basic search with default limit

from fetch_semantic_info import search_papers

papers = search_papers("Inference-Time Scaling")
for paper in papers:
    print(f"{paper['title']} ({paper['year']})")
    authors = ", ".join(a["name"] for a in paper["authors"])
    print(f"  Authors: {authors}")
    print(f"  Venue: {paper['venue']}")
    print(f"  Date: {paper['publicationDate']}")
    print()

Example 2: Search with a custom limit

from fetch_semantic_info import search_papers

# Fetch the single most recent paper
papers = search_papers("Chain of Thought Reasoning", limit=1)
if papers:
    latest = papers[0]
    print(f"Latest paper: {latest['title']}")
    print(f"Paper ID: {latest['paperId']}")
else:
    print("No papers found or API error occurred.")

Example 3: Handling empty results

from fetch_semantic_info import search_papers

papers = search_papers("xyznonexistenttopic12345", limit=10)
if not papers:
    print("No papers found. Check your query or try again later.")
else:
    print(f"Found {len(papers)} papers.")

Example 4: Command-line integration

# The main script uses search_papers internally:
python fetch_semantic_info.py --paper_name "Reward Modeling"
# This calls search_papers("Reward Modeling", limit=1) and updates README.md

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment