Functions to conveniently run asynchronous Ollama workflows, including RAG support.
Project description
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:
- Analyze Text Stored in a Dataframe Column
- Extract Missing Metadata Information from a Text Stored in a Dataframe Column
- Create "Fake" LLM Survey Respondents with given characteristics and make them answer your survey questions
- Retrieve Information stored in a separate vector database (Retrieval Augmented Generation (RAG))
The asynchronous running of the functions is based on their ability to:
- 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.
- 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:
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.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.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 functiongenerate_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:
- 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).
- At query time, the retriever fetches the top-k most relevant chunks for each input text.
- Those chunks are injected as “Context:” system messages before your user prompt, grounding the LLM’s answer in your corpus.
- 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:
-
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. -
build_retriever_async(): An async version of the above—ideal in Jupyter or anyasyncworkflow. It batches your texts into large embed requests (configurable viabatch_size) and throttles concurrency (max_concurrency) to maximize throughput while avoiding overload. -
RAG Integration in
run_analysis(): You can now pass one—or a list—of retrievers directly intorun_analysis(...).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ollama_run_async-0.2.5.tar.gz.
File metadata
- Download URL: ollama_run_async-0.2.5.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
580cef560cbd683ebbb22263a82fc4df901ec103e8791f8badde54a019513bbc
|
|
| MD5 |
21125c84d35897ac851b5914d70e210a
|
|
| BLAKE2b-256 |
ecfdf3cafa5fbb50a480a1c1f2f250f778f75e7a5a2a7ef8aba07aa4d77f00b7
|
Provenance
The following attestation bundles were made for ollama_run_async-0.2.5.tar.gz:
Publisher:
python-publish.yml on Quikii/Ollama-run-async
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ollama_run_async-0.2.5.tar.gz -
Subject digest:
580cef560cbd683ebbb22263a82fc4df901ec103e8791f8badde54a019513bbc - Sigstore transparency entry: 246023171
- Sigstore integration time:
-
Permalink:
Quikii/Ollama-run-async@c22b68caa8975584f228b929bd75af162a37d27d -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/Quikii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c22b68caa8975584f228b929bd75af162a37d27d -
Trigger Event:
release
-
Statement type:
File details
Details for the file ollama_run_async-0.2.5-py3-none-any.whl.
File metadata
- Download URL: ollama_run_async-0.2.5-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cbb247b2e2b2c33e4eb09e35ca453e9cfab69e8ba629749a8614e1dc07ff0b9
|
|
| MD5 |
192652fc22fa3afac1d3a7642a83093f
|
|
| BLAKE2b-256 |
5841259fa0e97ea83e2677fb1de2ad3baeb18fae007e16f62496343c733ea5aa
|
Provenance
The following attestation bundles were made for ollama_run_async-0.2.5-py3-none-any.whl:
Publisher:
python-publish.yml on Quikii/Ollama-run-async
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ollama_run_async-0.2.5-py3-none-any.whl -
Subject digest:
6cbb247b2e2b2c33e4eb09e35ca453e9cfab69e8ba629749a8614e1dc07ff0b9 - Sigstore transparency entry: 246023172
- Sigstore integration time:
-
Permalink:
Quikii/Ollama-run-async@c22b68caa8975584f228b929bd75af162a37d27d -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/Quikii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c22b68caa8975584f228b929bd75af162a37d27d -
Trigger Event:
release
-
Statement type: