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
resource = rs.rsc("./rscFiles", force_update=False, max_workers=5, embed_workers=10) # 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

  • ํด๋”๊ธฐ๋ฐ˜ ์ •๋ฆฌ ์ง€์›. ./rscFiles ์ž…๋ ฅํ–ˆ์œผ๋ฉด rscFilesIndex ์ƒ์„ฑํ•˜๊ณ  ๊ทธ ์•„๋ž˜๋กœ ์ธ๋ฑ์Šค ์ •๋ฆฌ. index/์•„๋ž˜์— ์ƒ์„ฑ๋œ ์ž„๋ฒ ๋”ฉ์ด ์žˆ์œผ๋ฉด ๊ทธ๊ฑฐ ์“ฐ๋„๋ก ํ•จ.
  • Replace threadPool to asyncio (v1.2.* ~)
  • L2 ๊ธฐ๋ฐ˜ ๋ฒกํ„ฐ๊ฒ€์ƒ‰์™ธ HNSW ์ง€์›. (์ฒด๊ฐ์„ฑ๋Šฅ ๋น„๊ต) (v1.3.0~)
  • ์ž…๋ ฅํฌ๋งท ๋‹ค์–‘ํ™”. 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.0.21.tar.gz (12.2 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.0.21-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: easy_rag_llm-1.0.21.tar.gz
  • Upload date:
  • Size: 12.2 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.0.21.tar.gz
Algorithm Hash digest
SHA256 b268c0fa578f429c226f2bac2993be3c66a8e45641708ba97b18dbfc1d9eb78a
MD5 da782dfa55c5dfed750d50c7581084ef
BLAKE2b-256 e0760ef0a77c478a4811cb0833fe6fb8af626ef86547835f46f475b288689e7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easy_rag_llm-1.0.21-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.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 56d84d015e705042fc5fc5f4ccff3a8cc1024d7c9c232034f5e569b0e1619b48
MD5 0dd15517587ad85de2aafcb1482563b1
BLAKE2b-256 6d04d74b930874747ce933a127a461f5471e95d2ce92a40a66b0e18e2a3b14f5

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