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) # 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๋กœ ์„ค์ •ํ•˜์—ฌ ๊ฐ•์ œ์—…๋ฐ์ดํŠธ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ‡บ๐Ÿ‡ธ 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.17.tar.gz (11.7 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.17-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: easy_rag_llm-1.0.17.tar.gz
  • Upload date:
  • Size: 11.7 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.17.tar.gz
Algorithm Hash digest
SHA256 8502133afa048ba8d54c802f43579b2979ebdd2e5723dec74e38587da99abb0e
MD5 b30b9132dcd5a26e116a90ab4beb2772
BLAKE2b-256 c0c0d709b1c87bda31679da008913c55496804871ffe52f1fffe63c173f462f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easy_rag_llm-1.0.17-py3-none-any.whl
  • Upload date:
  • Size: 10.0 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.17-py3-none-any.whl
Algorithm Hash digest
SHA256 a901ebbb3d81b9c9318c16d0a2c5bb3105fa25c08bad01675ecaf078de1630d9
MD5 b5dda2ef689fe6baa00b1787dd39e93c
BLAKE2b-256 e790bb858f7c1abe1c81db487d6d24fbcfd1e22101e4e4844a41fab59e5e898e

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