Skip to main content

Ollama Async Logo

The functions presented in this package make it simple for researchers in social sciences to run several Large Language Models loaded through Ollama over documents stored in a data frame asynchronously (at once). As such, all models used here have to be downloaded through the Ollama interface (https://ollama.com/). With them you are able to:

  1. Analyze Text Stored in a Dataframe Column
  2. Extract Missing Metadata Information from a Text Stored in a Dataframe Column
  3. Create "Fake" LLM Survey Respondents with given characteristics and make them answer your survey questions
  4. Retrieve Information stored in a separate vector database (Retrieval Augmented Generation (RAG))

The asynchronous running of the functions is based on their ability to:

  1. Split: You run several models in parallel on many chunks of documents (the same model several times or different models per chunk). The text documents are stored as rows in a dataframe. This speeds up the computing time.
  2. Fanout: You run several models in parallel on the same chunks of documents (again, the same model several times or different models per chunk). Again, the text documents are stored as rows in a dataframe. This likewise speeds up the computing time, but primarily allows for convenient comparison of different model outputs.

The three basic functions of the package, in Async-RUN, that can either split and/or fan out over the dataframe, but do so in slightly different ways and for slightly different purposes:

  1. run_analysis(): Allows you to write one prompt, which then either splits or fans out over the text in the dataframe. The common tasks would be text labeling or sentiment analysis. The answer to the prompt might be conveniently structured in a JSON object, with specifiable keys.
  2. fill_missing_fields_from_csv(): Instead of writing a prompt, the second function is specifically designed for information extraction from the text (with the primary use case being metadata collection). It also allows for an output in a JSON format. Crucially, it also handles existing metadata information in the dataframe, so the model only extracts information that is not yet present.
  3. run_survey_responses(): The last function, instead of focusing on analysing existing text, creates fake survey responses based on a set of characteristics. The "fake" respondents are generated and stored in a data frame with the helper function generate_fake_survey_df(), which allows the creation of a representative (based on the target population) distribution of characteristics over these respondents. The use case is to have a potentially more accurate distribution of responses to survey questions prior to running the actual survey on real-life respondents.

In addition to LLM-only processing, this package supports RAG:

  1. You index your PDFs/CSVs into a FAISS or Chroma vector store, with each chunk carrying its original metadata (e.g. source filename, party label, CSV columns).
  2. At query time, the retriever fetches the top-k most relevant chunks for each input text.
  3. Those chunks are injected as “Context:” system messages before your user prompt, grounding the LLM’s answer in your corpus.
  4. This both improves factuality and lets you trace exactly which snippets (and their metadata) influenced each response.

The functions included in the Async-RAG part of the package let you simply build your own retriever database and then include in the run_analysis() pipeline:

  1. build_retriever(): A synchronous helper that ingests your PDFs and/or CSVs, splits them into overlapping chunks (either fixed‐size or sentence‐aware), embeds each chunk via Ollama (or any provided embedder), and builds a FAISS or Chroma vector index.

  2. build_retriever_async(): An async version of the above—ideal in Jupyter or any async workflow. It batches your texts into large embed requests (configurable via batch_size) and throttles concurrency (max_concurrency) to maximize throughput while avoiding overload.

  3. RAG Integration in run_analysis(): You can now pass one—or a list—of retrievers directly into run_analysis(...).

Metadata

Release files for ollama-run-async 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ollama-run-async 0.2.5
File Size Uploaded
ollama_run_async-0.2.5.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ollama-run-async 0.2.5
File Interpreter ABI Platform
ollama_run_async-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / ollama_run_async-0.2.5.tar.gz

Download URL ollama_run_async-0.2.5.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
580cef560cbd683ebbb22263a82fc4df901ec103e8791f8badde54a019513bbc
BLAKE2b-256 checksum
How to use checksums
ecfdf3cafa5fbb50a480a1c1f2f250f778f75e7a5a2a7ef8aba07aa4d77f00b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2025.

Transparency log

Release files / ollama_run_async-0.2.5-py3-none-any.whl

Download URL ollama_run_async-0.2.5-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cbb247b2e2b2c33e4eb09e35ca453e9cfab69e8ba629749a8614e1dc07ff0b9
BLAKE2b-256 checksum
How to use checksums
5841259fa0e97ea83e2677fb1de2ad3baeb18fae007e16f62496343c733ea5aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page