Skip to main content

Easily implement RAG workflows with pre-built modules.

Project description

easy_rag_llm

CAUTION

  • easy-rag-llm==1.0.* version is testing version. These versions are usually invalid.

๐Ÿ‡ฐ๐Ÿ‡ท ์†Œ๊ฐœ

  • easy_rag_llm๋Š” OpenAI ๋ฐ DeepSeek ๋ชจ๋ธ์„ ์ง€์›ํ•˜๋Š” ๊ฐ„๋‹จํ•œ RAG(์ •๋ณด ๊ฒ€์ƒ‰ ๋ฐ ์ƒ์„ฑ) ๊ธฐ๋ฐ˜ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ฐ„๋‹จํ•˜๊ฒŒ RAG LLM์„ ์„œ๋น„์Šค์— ํ†ตํ•ฉ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“ค์–ด์กŒ์Šต๋‹ˆ๋‹ค.
  • (2025.01.16 ๊ธฐ์ค€/ v1.1.0) ํ•™์Šต๊ฐ€๋Šฅํ•œ ์ž๋ฃŒ ํฌ๋งท์€ PDF์ž…๋‹ˆ๋‹ค.

๐Ÿ‡บ๐Ÿ‡ธ Introduction

  • easy_rag_llm is a lightweight RAG-based service that supports both OpenAI and DeepSeek models. It is designed to seamlessly integrate RAG-based LLM functionalities into your service.
  • As of 2025-01-15 (v1.1.0), the supported resource format for training is PDF.

Usage

Install (https://pypi.org/project/easy-rag-llm/)

pip install easy_rag_llm

How to integrate to your service?

from easy_rag import RagService

rs = RagService(
    embedding_model="text-embedding-3-small", #Fixed to OpenAI model
    response_model="deepseek-chat",  # Options: "openai" or "deepseek-chat"
    open_api_key="your_openai_api_key_here",
    deepseek_api_key="your_deepseek_api_key_here",
    deepseek_base_url="https://api.deepseek.com",
)

rs2 = RagService( # this is example for openai chat model
    embedding_model="text-embedding-3-small",
    response_model="gpt-3.5-turbo",
    open_api_key="your_openai_api_key_here",
)

# Learn from all files under ./rscFiles
# force_update=False, chunkers=10, embedders=10, ef_construction=200, ef_search=100, M=48 is default parameter. you can tune them.
resource = rs.rsc("./rscFiles") # default workers are 10.

query = "Explain what is taught in the third week's lecture."
response, top_evidence = rs.generate_response(resource, query, evidence_num=5) # default evidence_num is 3.

print(response)

๐Ÿ‡ฐ๐Ÿ‡ท ์•ˆ๋‚ด.

  • pdf ์ œ๋ชฉ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ์ ์–ด์ฃผ์„ธ์š”. ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ์—๋Š” pdf์ œ๋ชฉ์ด ์ถ”์ถœ๋˜์–ด ๋“ค์–ด๊ฐ€๋ฉฐ, ๋‹ต๋ณ€ ๊ทผ๊ฑฐ๋ฅผ ์ถœ๋ ฅํ• ๋•Œ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • rs.rsc("./folder") ์ž‘๋™์‹œ faiss_index.bin๊ณผ metadata.json์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. ์ดํ›„์—” ์ด๋ฏธ ๋งŒ๋“ค์–ด์ง„ .bin๊ณผ .json์œผ๋กœ ๋‹ต๋ณ€์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ ํด๋”์— ์ƒˆ๋กœ์šด ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์ œ๊ฑฐํ•˜์—ฌ ๋ณ€๊ฒฝํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด force_update=True๋กœ ์„ค์ •ํ•˜์—ฌ ๊ฐ•์ œ์—…๋ฐ์ดํŠธ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
  • max_worker๋Š” pdf ๋ถ„ํ•  ๋ณ‘๋ ฌ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋™์‹œ์ž‘์—… ๊ฐœ์ˆ˜์ด๊ณ , embed_worker๋Š” ์ž„๋ฒ ๋”ฉ ์ž‘์—… ๋ณ‘๋ ฌ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋™์‹œ์ž‘์—… ๊ฐœ์ˆ˜์ž…๋‹ˆ๋‹ค. ๋‘˜๋‹ค ๊ธฐ๋ณธ๊ฐ’ 10์œผ๋กœ ๊ฐ๊ฐ CPU ์ฝ”์–ด๊ฐœ์ˆ˜์™€ api ratelimit์— ์˜ํ–ฅ์„ ๋ฐ›์œผ๋ฏ€๋กœ ์ ์ ˆํžˆ ์กฐ์ ˆํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ‡บ๐Ÿ‡ธ Note.

  • Ensure that your PDFs have clear titles. Extracted titles from the PDF metadata are used during training and for generating evidence-based responses.
  • Running rs.rsc("./folder") generates faiss_index.bin and metadata.json files. Subsequently, the system uses the existing .bin and .json files to generate responses. If you want to reflect changes by adding or removing files in the folder, you can enable forced updates by setting force_update=True.

release version.

  • 1.0.12 : Supported. However, the embedding model and chat model are fixed to OpenAI's text-embedding-3-small and deepseek-chat, respectively. Fixed at threadpool worker=10, which may cause errors in certain environments.
  • 1.1.0 : LTS version.

TODO

index/์•„๋ž˜์— ์ƒ์„ฑ๋œ ์ž„๋ฒ ๋”ฉ์ด ์žˆ์œผ๋ฉด ๊ทธ๊ฑฐ ์“ฐ๋„๋ก ํ•จ.

  • Replace threadPool to asyncio (v1.2.* ~)
  • ์ž…๋ ฅํฌ๋งท ๋‹ค์–‘ํ™”. pdf์™ธ ์ง€์›. (v1.4.* ~)

What can you do with this?

https://github.com/Aiden-Kwak/ClimateJudgeLLM

Author Information

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

easy_rag_llm-1.1.4.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_rag_llm-1.1.4-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file easy_rag_llm-1.1.4.tar.gz.

File metadata

  • Download URL: easy_rag_llm-1.1.4.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for easy_rag_llm-1.1.4.tar.gz
Algorithm Hash digest
SHA256 39469f50f3e9fc2ec76634604e910cf94db8c9a0f80e088cde3f91106f731dbb
MD5 34cd8511edcbf2bf94e64bbefe4bfee5
BLAKE2b-256 301899fc708ce086ed607f44935a2f7fb5f2005a6da976656f3426613f7d37f0

See more details on using hashes here.

File details

Details for the file easy_rag_llm-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: easy_rag_llm-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for easy_rag_llm-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b1ae5bb06c299ae8a54b920ae02104ebc382e2bb169f974252917b4f88afb660
MD5 3404691a291f6129cbf78456774c86e1
BLAKE2b-256 e62473a4b8aa5869d7bb8d8bcac137f3b608f062b940079bc7f25cd438e9fbf4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page