Skip to main content

LLM-retrieval based knowledge grounding

ragnosis contains tools for extracting hypotheses from scientific paper PDFs, extracting entities according to a user model, and grounding entities to ontology terms.

Installation

This project relies on langchain-rdf which should be installed separately.

To install langchain-rdf run:

pip install git+https://github.com/vemonet/langchain-rdf.git

ragnosis can be installed using pip:

pip install ragnosis

Usage

Hypothesis extraction

Hypotheses can be extracted from PDF files by running:

ragnosis extract_hypothesis path/to/paper.pdf [--model MODEL] [--temperature TEMP] [--out_file OUTPUT.txt]

Creating ontology indices

Before grounding entities, vector store indices must be created from your ontology files. One or more OWL files can be provided to create a single index. force_create will overwrite an existing index. The index will be saved in the index_directory with the name merged_index unless index_name is specified:

ragnosis create_index index_directory path/to/ontology1.owl path/to/ontology2.owl [--force_create] [--index_name NAME]

Hypothesis grounding

To ground entities in an input text to ontology terms:

ragnosis ground_hypothesis "your hypothesis text" path/to/yaml_map.yaml [--model MODEL] [--temperature TEMP] [--out_md OUTPUT.md]

The YAML file should map entity extraction categories to pre-built vector store indices, for example:

bio_components: path/to/go_index
genes_proteins: path/to/protein_index
taxa: path/to/taxonomy_index
small_molecules: path/to/chebi_index

where the path/to/go_index refers to pre-built vector store files path/to/go_index.faiss and path/to/go_index.pkl. A sample YAML file can be found in the ragnosis repository.

LLM Model Selection

For all commands that accept a --model parameter, you can specify:

  • OpenAI models with prefix openai/ (e.g., openai/gpt-4o)
  • Ollama models with prefix ollama/ (e.g., ollama/llama3)

The default model is openai/gpt-4o. When using OpenAI models, make sure to set your OPENAI_API_KEY environment variable before running the commands. For Ollama, make sure to have ollama installed and running.

Output Files

Most commands support saving output in markdown format using the --out_md parameter. For hypothesis extraction, use --out_file to save the extracted hypothesis as plain text. If the out file parameter is not provided, no output file will be saved. The output will be printed to the console in all cases.

Metadata

Release files for ragnosis 0.1.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 ragnosis 0.1.5
File Size Uploaded Provenance
ragnosis-0.1.5.tar.gz 12.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ragnosis 0.1.5
File Interpreter ABI Platform
ragnosis-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 23.7 kB

Release files / ragnosis-0.1.5.tar.gz

Download URL ragnosis-0.1.5.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
61f20aab5ea46f153326a9ffd03183709902c1466cba725422332fb3b10f5f6a
BLAKE2b-256 checksum
How to use checksums
c70b04589caa2d45738ca3cf13c70d679c2f9c5c09e1df4c5df0ef5d2c881295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.12

Release files / ragnosis-0.1.5-py3-none-any.whl

Download URL ragnosis-0.1.5-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e12703d4bdb66d52d4fc9973d343b77816be022ad1e6f2a900a76038853772e2
BLAKE2b-256 checksum
How to use checksums
d498c96b3307a88d1a38daaae3eee9f2e64f3051be0b84e07501537f165b9c84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.12

Security for ragnosis 0.1.5

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files No provenance

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