arXiv submission rate statistics
​https://info.arxiv.org/help/stats/2021_by_area/index.html

Project Description

The ArXiv repository is a vast and growing collection of academic papers that is now capturing a growing audience in industry, in particular for LLMs and AI. It’s also inspired several side projects, from Kaggle and similar platforms, aimed at making it easier to access.
​
It is a daunting corpus of documents to sift through wholesale. The URL identifiers, for one, use an indexing scheme (e.g., https://arxiv.org/abs/2407.06105 ) that has changed with growth and new categorization. The kinds of papers that compile or restate other research can have whole paragraphs dedicated to meticulous citation. And of course there are simply a lot of things. The chart above shows just the rate of growth in submissions from 1991, the year ArXiv was formed, through 2021.
​
ArXiv users could benefit even from integrating summaries of these documents with a Large Language Model (LLM). The natural language interaction offered by OpenAI, Claude, or similar services, make it plausible to review ArXiv content, without first learning how best to search it, and have the result cast in a conversational manner.
​
This project is an experiment in that direction. It uses a method of supplementing an LLM with additional data called Retrieval Augmented Generation (RAG). A number of paper abstracts are collected and included in a prompt sent to the LLM. The user agent asks the LLM to incorporate this data into its response.
​
The end goal is to incorporate this scheme into a Chat Notebook, such that a user agent can prompt the LLM for information that, unaided, it might otherwise respond to in tangential or even inaccurate ways. (It is after all the goal of a Generative AI system to keep a conversation going, even at the risk of regressing to standard search or calling up suspect data from the corpus.)

RAG Development

​By Gknor - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=139459823​RAG simplifies the process of adding domain-specific or updated information to an LLM. The RAG implementation starts with some data -- in our case, summaries taken from ArXiv documents -- that is encoded into a vector. In LLM parlance, a vector is called an embedding.The number of dimensions in an embedding factors into the LLM’s design and use. OpenAI models, for example, uses 1536 dimensions to represent a piece of text. ​Collected together in a vector database, the similarity of any two embeddings is calculated by a distance function. When two vectors are “close together,” they are deemed to be semantically similar. When an encoded prompt is tested against the database, the embeddings closest to it are returned. ​The user agent encapsulates the whole in a template to guide the LLM’s response, as simple as “use ArXiv data to answer the following question” or more detailed. This prompting adjunct is referred to as a tool, and so it’s common in RAG prompts to see “please use the tool!”

Testing Setup

A proof-of-technology demonstration in Wolfram Language is a straightforward affair, starting with connecting to the service and trying it out. There are a number of built-in services you can browse at will. (Note we can connect to both ArXiv and OpenAI this way):
In[]:=
$Services
Out[]=
{AI21,AlephAlpha,Anthropic,ArXiv,AWS,BingSearch,CharityEngine,ChemSpider,Cohere,CrossRef,DeepSeek,Dropbox,ElevenLabs,Facebook,Factual,FederalReserveEconomicData,Fitbit,Flickr,GoogleAnalytics,GoogleCalendar,GoogleContacts,GoogleCustomSearch,GoogleGemini,GooglePlus,GoogleSpeech,GoogleTranslate,Groq,HuggingFace,IBMQ,Instagram,IPFS,LinkedIn,MailChimp,MicrosoftTranslator,MistralAI,Mixpanel,MusicBrainz,OpenAI,OpenLibrary,OpenPHACTS,PaLM,PubChem,PubMed,Pushbullet,Reddit,RunKeeper,SeatGeek,SurveyMonkey,TogetherAI,Twilio,Twitter,Wikipedia,Yelp}
In[]:=
arxiv=ServiceConnect["ArXiv"]
Out[]=
ServiceObject
ArXiv
Not Connected

In this example we retrieve a single record from the Quantum Physics category to examine the format:
In[]:=
category=arxiv["CategorySearch",{"Query"->"quant-ph",MaxItems1}]
Out[]=
ID
URL
Updated
Published
Title
Summary
Author
DOI
Link
Comment
Name
9412001v1
http://arxiv.org/abs/quant-ph/9412001v1
Wed 21 Dec 1994 09:22:43
Wed 21 Dec 1994 09:22:43
Photon Statistics of a Two-Mode Squeezed Vacuum
We investigate the general case of the photon distribution of a two-mode squeezed vacuum and show that the distribution of photons among the two modes depends on four parameters: two squeezing parameters, the relative phase between the two oscillators and their spatial orientation. The distribution of the total number of photons depends only on the two squeezing parameters. We derive analytical expressions and present pictures for both distributions.
G. Schrade
10.1103/PhysRevA.48.2398
Title
doi
LATEX, 6 pages, Contribution to the third International Workshop on Squeezed States and Uncertainty Relations, Baltimore, August 1993
V. M. Akulin
Href
http://dx.doi.org/10.1103/PhysRevA.48.2398
W. P. Schleich
Rel
related
V. I. Man'ko
Href
http://arxiv.org/abs/quant-ph/9412001v1
Rel
alternate
Type
text/html
Title
pdf
Href
http://arxiv.org/pdf/quant-ph/9412001v1
Rel
related
4 total ›
columns 1–10 of 13
Connecting to the OpenAI service requires an API key, which can be added to the platform environment for ongoing use. There is no cost for persisting a connection indefinitely:
​
ServiceExecute is also available and useful for quick testing:
In[]:=
ServiceExecute[openAI,"Completion",{"Prompt"->"What I know about ArXiv is..."}]
Out[]=
{"text""\\nArXiv is an open-access digital repository for scientific papers, primarily in","index"0,"logprobs"Null,"finish_reason""length"}

Getting Data

The guardrails for a short-term project include drawing enough ArXiv data to demonstrate RAG to advantage, but without violating the terms of service. ArXiv encourages retrieving “descriptive metadata” for projects that aim to broaden access to the service, but there are still reasonable rate limits and terms to observe.
​
Queries through the ArXiv service connection were challenging. Retrieving records was inconsistent, possibly due to competing requests. There wasn’t enough time here to investigate the causes for error or perhaps denial of service. We ran the query below several times, sometimes successful, sometimes not:
In[]:=
res=arxiv["Search",{"Query""quant-ph",MaxItems1000,"StartIndex"1}]//Normal
The response renders to a Dataset view by default, but as shown above in the single record test, it is cumbersome to inspect. We can view a record more easily with a Normal transformation. Each record is an association, further nested to accommodate multiple authors and link references.
In[]:=
Keys[res[[1]]]
Out[]=
{ID,URL,Updated,Published,Title,Summary,Author,Link,PrimaryCategory,Category}
In[]:=
res[[600]]
Out[]=
ID0009028v1,URLhttp://arxiv.org/abs/quant-ph/0009028v1,Updated
Fri 8 Sep 2000 09:00:34GMT
,Published
Fri 8 Sep 2000 09:00:34GMT
,TitleNew schemes for manipulating quantum states using a Kerr cell,SummaryIn this proceeding we describe various proposals of application of an high coefficient Kerr cell to quantum states manipulation, ranging from fast modulation of quantum interference, GHZ states generation, Schroedinger cats creation, translucent eavesdropping, etc.,Author{NameM. Genovese,NameC. Novero},Commentproc. of QCM&C,Link{Hrefhttp://arxiv.org/abs/quant-ph/0009028v1,Relalternate,Typetext/html,Titlepdf,Hrefhttp://arxiv.org/pdf/quant-ph/0009028v1,Relrelated,Typeapplication/pdf},PrimaryCategory{Quantum Physics},Category{Quantum Physics,Physics - Optics}
In[]:=
res[[600]][[6]]
Out[]=
In this proceeding we describe various proposals of application of an high coefficient Kerr cell to quantum states manipulation, ranging from fast modulation of quantum interference, GHZ states generation, Schroedinger cats creation, translucent eavesdropping, etc.
We also saw cases where the Summary text might not transform in a meaningful way:
The text as it appears on the website:
A consideration for future development is how best to treat special notations in a natural language processing (NLP) context.

Initial Process and Results

From here the path forward would appear plain. Convert each summary into an embedding, populate the vector database, test against an LLM with and without the RAG data and observe the result. The approach ultimately broke down, for lack of time, a steep learning curve writing functional code in a notebook format.
​
We started out making use of an experimental feature in an upcoming release called SemanticSearchIndex. This object is backed by a VectorDatabase builtin. It uses SentenceBERT as its feature extractor (i.e., text parser) and a EuclideanDistance function. This means the embeddings and database population are handled in-house -- quite convenient.
​
The first model used 5000 ArXiv records from the Quantum Physics category. It was paired with an LLMTool that could match up to 15 items in the database against the query string:
An LLMEvaluator uses one or more LLMTool objects to build a ChatObject, which in turn supports ChatEvaluate:
As expected, the LLM response had the lazy cut-and-paste feel that tells us it is out of its depth. Next we tried to invoke our tool in the prompt:
We didn’t see the dialog box to indicate the tool was in play. What was surprising was the citation of specific ArXiv papers, including authors and links. In prior testing, OpenAI said it didn’t have access to the ArXiv site and recommended we browse it ourselves. It remains unclear by what influence this change took place.

Things Fall Apart, The Center Cannot Hold

The project work that followed was a rich proving ground for several hard lessons. A few of them are described.
​
At about 9000 records, populating the SemanticSearchIndex threw errors possibly related to unfriendly elements in the text, perhaps blank spaces or metacharacters in an empty field. We also questioned whether the StartIndex property worked properly, so we tested for overlap.
Previous runs of confirmed the indexing was working.
​
We decided to try getting records in XML format that would be easier to clean and inspect, and included a batch process with a timed pause.
We also decided to use OpenAI’s embedding service:

Conclusions

The RAG model is a well-established pattern with active investigations into more sophisticated and powerful approaches. This project could have easily been implemented in Python and integrated into the Wolfram platform, but there wasn’t much learn from that exercise. We took our chances with experimental tools, and a learning curve to the platform that was steeper than expected.
​
I have many thanks to give, beginning with the encouragement and support of my colleagues. This project started with Stephen Wolfram, who saw it as a “crunchy” undertaking but sees the value of this tool for this community. I would not have got half so far without Christopher Wolfram and John McNally for their support, ideas, and code I could not have written without much more time.

Cite This Notebook

“Building a RAG for arXiv data”
by Michael Ernest​
​https://community.wolfram.com/groups/-/m/t/3211009