Tool

Ingest and Query Semantic Scholar Research Papers

Loads scholarly papers from Semantic Scholar into LlamaIndex Documents for citation-backed research Q&A.

Works with semanticscholaropenaillama index

Maintainer of this project? Claim this page to edit the listing.


82
Spark score
out of 100
Updated 26 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Access and process scholarly articles from Semantic Scholar to build a knowledge base for research and analysis. Enables querying of academic literature with citation support.

Outcomes

What it gets done

01

Load research papers from Semantic Scholar based on search queries.

02

Extract full text from open access PDFs when available.

03

Index documents for efficient retrieval and querying.

04

Generate answers with citations based on the indexed research.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-semanticscholar | bash

Overview

Semantic Scholar Loader

A LlamaIndex reader that loads Semantic Scholar papers into Documents for citation-backed research question answering. Use when researching a topic and needing academic papers retrieved and indexed with attributed source citations.

What it does

A LlamaIndex reader that retrieves scholarly articles from the Semantic Scholar database based on a research query, loading them as Documents for citation-backed question answering over academic literature.

When to use - and when NOT to

Use this loader when researching a topic and needing to pull relevant academic papers into a LlamaIndex pipeline for retrieval-augmented Q&A with source citations. Not a fit for non-academic content, or for topics where full-text extraction is needed but the papers aren't open access (full-text extraction only works for open-access PDFs).

Inputs and outputs

Installed via llama-index-readers-semanticscholar (plus llama-index-llms-openai for the example pipeline). Uses two key concepts: query_space (a broad research area) and query_string (a specific question against documents in that space). SemanticScholarReader().load_data(query=query_space, limit=N) retrieves up to N relevant papers; passing full_text=True additionally downloads open-access PDFs and extracts their text.

The full example workflow loads papers on "large language models", builds a VectorStoreIndex over them with an OpenAI-backed ServiceContext, and queries via a CitationQueryEngine (configured with similarity_top_k and citation_chunk_size) so that answers come with attributed source nodes. Each returned document carries metadata including venue, publication year, Semantic Scholar paper ID, citation count, open-access PDF availability, authors, and title - shown in the example output alongside a synthesized answer about LLM limitations backed by three cited papers.

Integrations

Connects to the Semantic Scholar API for paper retrieval, and integrates with LlamaIndex's VectorStoreIndex and CitationQueryEngine (using an OpenAI LLM in the example) to produce citation-attributed research answers.

Who it's for

Researchers and developers building citation-aware Q&A systems over academic literature who need to retrieve and index Semantic Scholar papers with full metadata rather than manually searching and copying paper references.

documents = s2reader.load_data(query=query_space, limit=10)
query_engine = CitationQueryEngine.from_args(index, similarity_top_k=3, citation_chunk_size=512)
Source README

Semantic Scholar Loader

pip install llama-index-readers-semanticscholar

pip install llama-index-llms-openai

Welcome to Semantic Scholar Loader. This module serves as a crucial utility for researchers and professionals looking to get scholarly articles and publications from the Semantic Scholar database.

For any research topic you are interested in, this loader reads relevant papers from a search result in Semantic Scholar into Documents.

Please go through demo_s2.ipynb

Some preliminaries -

  • query_space : broad area of research
  • query_string : a specific question to the documents in the query space

UPDATE :

To download the open access pdfs and extract text from them, simply mark the full_text flag as True :

s2reader = SemanticScholarReader()
documents = s2reader.load_data(query_space, total_papers, full_text=True)

Usage

Here is an example of how to use this loader in llama_index and get citations for a given query.

LlamaIndex

from llama_index.llms.openai import OpenAI
from llama_index.core.query_engine import CitationQueryEngine
from llama_index.core import VectorStoreIndex, ServiceContext
from llama_index.readers.semanticscholar import SemanticScholarReader

s2reader = SemanticScholarReader()

### narrow down the search space
query_space = "large language models"

### increase limit to get more documents
documents = s2reader.load_data(query=query_space, limit=10)

service_context = ServiceContext.from_defaults(
    llm=OpenAI(model="gpt-3.5-turbo", temperature=0)
)
index = VectorStoreIndex.from_documents(
    documents, service_context=service_context
)

query_engine = CitationQueryEngine.from_args(
    index,
    similarity_top_k=3,
    citation_chunk_size=512,
)

### query the index
response = query_engine.query("limitations of using large language models")
print("Answer: ", response)
print("Source nodes: ")
for node in response.source_nodes:
    print(node.node.metadata)

Output

Answer:  The limitations of using large language models include the struggle to learn long-tail knowledge [2], the need for scaling by many orders of magnitude to reach competitive performance on questions with little support in the pre-training data [2], and the difficulty in synthesizing complex programs from natural language descriptions [3].
Source nodes:
{'venue': 'arXiv.org', 'year': 2022, 'paperId': '3eed4de25636ac90f39f6e1ef70e3507ed61a2a6', 'citationCount': 35, 'openAccessPdf': None, 'authors': ['M. Shanahan'], 'title': 'Talking About Large Language Models'}
{'venue': 'arXiv.org', 'year': 2022, 'paperId': '6491980820d9c255b9d798874c8fce696750e0d9', 'citationCount': 31, 'openAccessPdf': None, 'authors': ['Nikhil Kandpal', 'H. Deng', 'Adam Roberts', 'Eric Wallace', 'Colin Raffel'], 'title': 'Large Language Models Struggle to Learn Long-Tail Knowledge'}
{'venue': 'arXiv.org', 'year': 2021, 'paperId': 'a38e0f993e4805ba8a9beae4c275c91ffcec01df', 'citationCount': 305, 'openAccessPdf': None, 'authors': ['Jacob Austin', 'Augustus Odena', 'Maxwell Nye', 'Maarten Bosma', 'H. Michalewski', 'David Dohan', 'Ellen Jiang', 'Carrie J. Cai', 'Michael Terry', 'Quoc V. Le', 'Charles Sutton'], 'title': 'Program Synthesis with Large Language Models'}

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.