LitRevAI (Literature Review AI) is a Python package designed to automate systematic literature reviews using natural language processing (NLP) techniques.
Project description
LitRevAI
Table of Contents
Description
LitRevAI (Literature Review AI) is a Python package designed to automate systematic literature reviews using natural language processing (NLP) techniques. It supports the import of documents from Zotero, including metadata, for streamlined analysis. By integrating Retrieval-Augmented Generation with advanced topic modeling via BERTopic, LitRevAI offers a powerful tool for efficient, data-driven literature reviews.
Installation
pip install litrevai
Basic Usage
Using LitRevAI typically follows these steps:
- Import Documents: Load documents, including metadata, from Zotero or other sources.
- Create a Project: Set up a new project to organize and analyze your literature review.
- Add Documents to the Project: Include the imported documents in the project for analysis.
- Create a Query: Formulate a query to retrieve relevant information from the documents.
- Run the Query: Apply the query across all documents in the project to gather responses.
- Refine or Analyze: Use the responses to either ask additional questions or generate a topic model.
RAG
from litrevai import LiteratureReview, YesNoPrompt, ListPrompt, HuggingfaceModel
# Access Database
lr = LiteratureReview('db')
# Import Documents from Zotero Personal Library
lr.import_zotero(filter_libraries=['Personal'])
# Create a project
project = lr.create_project(name='New Project')
# Add all items to the project
project.add_items(lr.items)
# Create a query using a YesNoPrompt
prog_query = project.create_query(
name='programming',
prompt=YesNoPrompt(
question="Does the document report on a study or experiment involving programming?"
)
)
# Running a query requires to define an inference model
model = HuggingfaceModel(model='meta-llama/Llama-3.1-8B-Instruct')
lr.set_llm(model)
# Run query over all documents in the project
prog_query.run()
print(prog_query.responses)
# Create another Query
concept_query = project.create_query(
name='prog_concepts',
prompt=ListPrompt(
question="What programming concepts are mentioned in the document? List all of them!",
n=10
)
)
# Use the responses from the last query as a filter
concept_query.run(items=prog_query.as_filter())
print(concept_query.responses)
Topic Modelling
from litrevai import LiteratureReview
lr = LiteratureReview('db')
query = lr.queries['prog_concepts']
topic_model = query.create_topic_model()
topic_model.summary()
Full-Text Search
df = project.search('Epistemic Programming')
df
Large Language Models
To use Retrieval-Augmented Generation (RAG) or topic modeling in LitRevAI a large language model (LLM) is required.
LitRevAI provides basic support for LLM inference via Huggingface and OpenAI.
To enable these integrations, it’s recommended to store the required API keys either in an .env file within
the working directory or in environment variables.
HF_TOKEN=""
OPENAI_API_KEY=""
Alternatively, you can pass them directly to the constructor:
from litrevai.llm import HuggingfaceModel, OpenAIModel
api_key = 'xy'
model = 'model_name_or_url'
model = HuggingfaceModel(api_key=api_key, model=model)
model = OpenAIModel(api_key=api_key, model=model)
License
litrevai is distributed under the terms of the MIT license.
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 litrevai-0.0.2.tar.gz.
File metadata
- Download URL: litrevai-0.0.2.tar.gz
- Upload date:
- Size: 924.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66e81be0ad39f90333c8d2cfabcd2228bc37f79234bab31217b185203b711316
|
|
| MD5 |
ec5b10f0f16e084609435af34965decd
|
|
| BLAKE2b-256 |
f9684f90b451c8efc1b07a32832122000916e04ed6054f6bf8d49df571a7d3b6
|
File details
Details for the file litrevai-0.0.2-py3-none-any.whl.
File metadata
- Download URL: litrevai-0.0.2-py3-none-any.whl
- Upload date:
- Size: 36.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91d5f575dd99b4a3552be666bde0446a98c5b860431ec9e3994bd98a12629f66
|
|
| MD5 |
f91167db9e83e421ede3c776b09e203d
|
|
| BLAKE2b-256 |
8329c83b85572fbb60693c156a587fa357fb60ab3b8f49b721a326fc1f5e36f1
|