### Install AutoRAG Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs the core AutoRAG package using pip. This is the primary method for getting started with AutoRAG. ```bash pip install AutoRAG ``` -------------------------------- ### Start vLLM API Server Source: https://marker-inc-korea.github.io/AutoRAG/nodes/generator/vllm_api Instructions on how to start the vLLM API server. It references the official vLLM documentation for detailed setup and usage of the OpenAI-compatible API server. ```shell # Start vLLM API server # Refer to vLLM documentation for the exact command and options. # Example: python -m vllm.entrypoints.openai.api_server --host 0.0.0.0 --port 8012 # The port 8012 is commonly used for the vLLM API server. ``` -------------------------------- ### Install Recommended Libraries Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs PyOpenSSL and nltk, which are recommended for full AutoRAG features. It also includes commands to download necessary nltk data like 'punkt_tab' and 'averaged_perceptron_tagger_eng'. ```bash pip install --upgrade pyOpenSSL pip install nltk python3 -c "import nltk; nltk.download('punkt_tab')" python3 -c "import nltk; nltk.download('averaged_perceptron_tagger_eng')" ``` -------------------------------- ### Install Requirements for Testing and Docs Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs additional packages required for running tests and building documentation when building AutoRAG from source. ```bash pip install -r tests/requirements.txt pip install -r docs/requirements.txt ``` -------------------------------- ### Prompt Maker Configuration Example Source: https://marker-inc-korea.github.io/AutoRAG/_sources/nodes/prompt_maker/prompt_maker.md Example of a config.yaml file demonstrating the setup for the prompt_maker node, including strategy parameters and module definitions. ```yaml node_lines: - node_line_name: post_retrieve_node_line # Arbitrary node line name nodes: - node_type: prompt_maker strategy: metrics: [bleu, meteor, rouge, sem_score] speed_threshold: 10 token_threshold: 1000 tokenizer: gpt-3.5-turbo generator_modules: - module_type: llama_index_llm llm: openai model: [gpt-3.5-turbo-16k, gpt-3.5-turbo-1106] modules: - module_type: fstring prompt: ["Tell me something about the question: {query} \n\n {retrieved_contents}", "Question: {query} \n Something to read: {retrieved_contents} \n What's your answer?"] ``` -------------------------------- ### Install AutoRAG Source: https://marker-inc-korea.github.io/AutoRAG/_sources/index.rst Installs the AutoRAG package using pip. This is the primary method to get started with AutoRAG on your local machine. ```bash pip install AutoRAG ``` -------------------------------- ### Run AutoRAG GUI from Source Source: https://marker-inc-korea.github.io/AutoRAG/_sources/gui/gui.md This sequence of commands guides users through building and running the AutoRAG GUI application directly from the source code. It involves navigating to the frontend directory, configuring environment variables, installing dependencies, building the application, and starting the server. ```bash cd autorag-frontend yarn install npm run build npm run start ``` -------------------------------- ### Install AutoRAG from Source Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs AutoRAG in editable mode after cloning the repository. This is useful for development or contributing to the project. ```bash cd AutoRAG pip install -e . ``` -------------------------------- ### Clone AutoRAG Repository Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Clones the AutoRAG GitHub repository to build the project from source. ```bash git clone https://github.com/Marker-Inc-Korea/AutoRAG.git ``` -------------------------------- ### Install AutoRAG with GPU Support Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs AutoRAG with additional dependencies required for GPU acceleration, enabling faster processing for compatible hardware. ```bash pip install "AutoRAG[gpu]" ``` -------------------------------- ### Install AutoRAG with Parsing Support Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs AutoRAG with dependencies necessary for document parsing. This requires external system packages like libmagic, tesseract, and poppler to be installed first. ```bash pip install "AutoRAG[parse]" ``` -------------------------------- ### Run Autorag GPU Version Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Shows how to execute the autorag:gpu Docker image, enabling GPU acceleration. It requires CUDA and cuDNN on the host and uses the --gpus all flag for GPU access. ```bash docker run --rm -it \ -v ~/.cache/huggingface:/cache/huggingface \ -v $(pwd)/sample_config:/usr/src/app/sample_config \ -v $(pwd)/projects:/usr/src/app/projects \ -e HF_HOME=/cache/huggingface \ --gpus all \ autoraghq/autorag:gpu evaluate \ --config /usr/src/app/sample_config/rag/simple/simple_openai.yaml \ --qa_data_path /usr/src/app/projects/test01/qa_validation.parquet \ --corpus_data_path /usr/src/app/projects/test01/corpus.parquet \ --project_dir /usr/src/app/projects/test01 ``` -------------------------------- ### Install AutoRAG GUI with Docker Compose Source: https://marker-inc-korea.github.io/AutoRAG/_sources/gui/gui.md This snippet demonstrates the commands to clone the AutoRAG repository, including submodules, and then run the application using Docker Compose. It's the recommended method for a quick setup. ```bash git clone --recurse-submodules https://github.com/Marker-Inc-Korea/AutoRAG.git cd AutoRAG docker compose up ``` -------------------------------- ### Run Autorag Evaluation with Custom HF Cache Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Demonstrates how to run the autorag:api Docker image for evaluation. It shows mounting Hugging Face cache to a custom location and setting the HF_HOME environment variable for efficient model loading. ```bash docker run --rm -it \ -v ~/.cache/huggingface:/cache/huggingface \ -v $(pwd)/sample_config:/usr/src/app/sample_config \ -v $(pwd)/projects:/usr/src/app/projects \ -e HF_HOME=/cache/huggingface \ autoraghq/autorag:api evaluate \ --config /usr/src/app/sample_config/rag/simple/simple_openai.yaml \ --qa_data_path /usr/src/app/projects/test01/qa_validation.parquet \ --corpus_data_path /usr/src/app/projects/test01/corpus.parquet \ --project_dir /usr/src/app/projects/test01 ``` -------------------------------- ### vllm Module Example Configuration Source: https://marker-inc-korea.github.io/AutoRAG/nodes/generator/vllm An example configuration snippet demonstrating how to set up the vllm module in a config.yaml file for AutoRAG. ```yaml modules: - module_type: vllm llm: mistralai/Mistral-7B-Instruct-v0.2 temperature: [0.1, 1.0] max_tokens: 512 ``` -------------------------------- ### Window Replacement Example Config Source: https://marker-inc-korea.github.io/AutoRAG/nodes/prompt_maker/window_replacement Example configuration for the Window Replacement prompt maker module, specifying the prompt templates to be used. The prompt string must contain `{query}` and `{retrieved_contents}` placeholders. ```YAML modules: -module_type:window_replacement prompt:["Tellmesomethingaboutthequestion:{query}\n\n{retrieved_contents}", "Question:{query}\nSomethingtoread:{retrieved_contents}\nWhat'syouranswer?"] ``` -------------------------------- ### Install AutoRAG Source: https://marker-inc-korea.github.io/AutoRAG/index Installs the AutoRAG library using pip. This is the primary method to get started with the AutoRAG tool for building and optimizing RAG pipelines. ```bash pip install AutoRAG ``` -------------------------------- ### Create .env File for API Key Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Example content for a .env file to store sensitive API keys, such as the OPENAI_API_KEY. This file should be placed in the root folder. ```dotenv OPENAI_API_KEY=sk-...your-api-key... ``` -------------------------------- ### Qdrant Configuration Example Source: https://marker-inc-korea.github.io/AutoRAG/_sources/integration/vectordb/qdrant.md Provides an example YAML configuration for setting up the Qdrant vector database with specific embedding models and client types. ```yaml - name: openai_qdrant db_type: qdrant embedding_model: openai_embed_3_large collection_name: openai_embed_3_large client_type: docker embedding_batch: 50 similarity_metric: cosine dimension: 1536 ``` ```yaml vectordb: - name: openai_qdrant db_type: qdrant embedding_model: openai_embed_3_large collection_name: openai_embed_3_large client_type: docker embedding_batch: 50 similarity_metric: cosine dimension: 1536 node_lines: - node_line_name: retrieve_node_line # Arbitrary node line name nodes: - node_type: semantic_retrieval strategy: metrics: [retrieval_f1, retrieval_recall, retrieval_precision] top_k: 3 modules: - module_type: vectordb vectordb: openai_qdrant - node_line_name: post_retrieve_node_line # Arbitrary node line name nodes: - node_type: prompt_maker strategy: metrics: [bleu, meteor, rouge] modules: - module_type: fstring prompt: "Read the passages and answer the given question. Question: {query} Passage: {retrieved_contents} Answer : " - node_type: generator strategy: metrics: [bleu, rouge] modules: - module_type: llama_index_llm llm: openai model: [ gpt-4o-mini ] ``` -------------------------------- ### Access Autorag Container for Debugging Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Provides a command to start a Bash shell inside the autorag:api Docker container. This is useful for manual inspection, running commands, or troubleshooting issues within the container environment. ```bash docker run --rm -it --entrypoint /bin/bash autoraghq/autorag:api ``` -------------------------------- ### Install AutoRAG for Japanese Language Support Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs optional dependencies for Japanese language processing. ```bash pip install "AutoRAG[ja]" ``` -------------------------------- ### Run AutoRAG Web Interface with Runner (from Trial Folder) Source: https://marker-inc-korea.github.io/AutoRAG/_sources/deploy/web.md Initializes the AutoRAG Runner from a trial folder and starts the web interface, with options to configure server binding and public sharing. The `share=True` option generates a public link. ```python from autorag.deploy import Runner runner = Runner.from_trial_folder('your/path/to/trial_folder') runner.run_web(server_name="0.0.0.0", server_port=7680, share=True) ``` -------------------------------- ### Chroma Initialization via YAML Source: https://marker-inc-korea.github.io/AutoRAG/_sources/integration/vectordb/chroma.md Example YAML structure for initializing the Chroma vector store, specifying database type, client type, and connection details. ```yaml vectordb: - name: chroma_default db_type: chroma client_type: persistent embedding_model: mock collection_name: openai path: ${PROJECT_DIR}/resources/chroma ``` -------------------------------- ### Install AutoRAG for Korean Language Support Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Installs optional dependencies for Korean language processing. Requires JDK 17 to be installed and configured in the environment path for konlpy. ```bash pip install "AutoRAG[ko]" ``` -------------------------------- ### Start vLLM API Server Source: https://marker-inc-korea.github.io/AutoRAG/_sources/nodes/generator/vllm_api.md Command to launch the vLLM API server. It specifies the model to serve and the port for the API endpoint. ```bash vllm serve Qwen/Qwen2.5-14B-Instruct-AWQ -q awq --port 8012 ``` -------------------------------- ### Milvus Configuration Examples Source: https://marker-inc-korea.github.io/AutoRAG/_sources/integration/vectordb/milvus.md Provides example YAML configurations for setting up the Milvus vector database, including connection details, embedding model specifications, and retrieval node parameters. ```YAML - name: openai_milvus db_type: milvus embedding_model: openai_embed_3_large collection_name: openai_embed_3_large uri: ${MILVUS_URI} token: ${MILVUS_TOKEN} embedding_batch: 50 similarity_metric: cosine index_type: IVF_FLAT params: nlist: 16384 ``` ```YAML vectordb: - name: openai_milvus db_type: milvus embedding_model: openai_embed_3_large collection_name: openai_embed_3_large uri: ${MILVUS_URI} token: ${MILVUS_TOKEN} embedding_batch: 50 similarity_metric: cosine index_type: IVF_FLAT params: nlist: 16384 node_lines: - node_line_name: retrieve_node_line # Arbitrary node line name nodes: - node_type: semantic_retrieval strategy: metrics: [retrieval_f1, retrieval_recall, retrieval_precision] top_k: 3 modules: - module_type: vectordb vectordb: openai_milvus - node_line_name: post_retrieve_node_line # Arbitrary node line name nodes: - node_type: prompt_maker strategy: metrics: [bleu, meteor, rouge] modules: - module_type: fstring prompt: "Read the passages and answer the given question. Question: {query} Passage: {retrieved_contents} Answer : " - node_type: generator strategy: metrics: [bleu, rouge] modules: - module_type: llama_index_llm llm: openai model: [ gpt-4o-mini ] ``` -------------------------------- ### FlashRank Reranker Configuration Example Source: https://marker-inc-korea.github.io/AutoRAG/nodes/passage_reranker/flashrank_reranker An example configuration file demonstrating how to set up the FlashRank reranker module, including batch size and the specific model to be used. ```yaml -module_type:flashrank_reranker batch:32 model:"ms-marco-MiniLM-L-12-v2" ``` -------------------------------- ### Example config.yaml for Query Expansion Source: https://marker-inc-korea.github.io/AutoRAG/nodes/query_expansion/query_expansion An example configuration file demonstrating how to set up the Query Expansion node within AutoRAG. It includes strategy parameters, retrieval modules, and specific module configurations. ```yaml node_lines: -node_line_name:pre_retrieve_node_line# Arbitrary node line name nodes: -node_type:query_expansion strategy: metrics:[retrieval_f1,retrieval_recall,retrieval_precision] speed_threshold:10 top_k:10 retrieval_modules: -module_type:bm25 -module_type:vectordb vectordb:default modules: -module_type:pass_query_expansion -module_type:query_decompose llm:openai temperature:[0.2,1.0] -module_type:hyde llm:openai max_token:64 ``` -------------------------------- ### Run AutoRAG Web Interface from Trial Folder Source: https://marker-inc-korea.github.io/AutoRAG/tutorial Initializes the GradioRunner using the configuration and results from a previous AutoRAG trial directory, then launches the web interface. This allows for easy deployment of optimized pipelines. ```python from autorag.deploy import GradioRunner runner = GradioRunner.from_trial_folder('/your/path/to/trial_dir') runner.run_web() ``` -------------------------------- ### VoyageAI Reranker Setup Source: https://marker-inc-korea.github.io/AutoRAG/nodes/passage_reranker/voyageai_reranker Instructions for setting up the VoyageAI API key, either via environment variables or directly in the configuration file. ```shell export VOYAGE_API_KEY=your_voyageai_api_key ``` -------------------------------- ### Query Decompose Configuration Example Source: https://marker-inc-korea.github.io/AutoRAG/nodes/query_expansion/query_decompose An example configuration file (config.yaml) demonstrating how to set up the query_decompose module, specifying the generator module type and LLM. ```YAML modules: -module_type:query_decompose generator_module_type:llama_index_llm llm:openai model:[gpt-3.5-turbo-16k,gpt-3.5-turbo-1106] ``` -------------------------------- ### Get Start and End Index (Python) Source: https://marker-inc-korea.github.io/AutoRAG/_modules/autorag/data/utils/util Finds the starting and ending indices of a substring within a larger string. If the substring is not found, it returns (0, 0). This utility is useful for text processing and locating specific patterns. ```python defget_start_end_idx(original_text: str, search_str: str) -> Tuple[int, int]: """Get the start and end index of a search string in the original text. Args: original_text: str: The text to search within. search_str: str: The string to search for. Returns: Tuple[int, int]: A tuple containing the start and end index (inclusive) of the search string. """ start_idx = original_text.find(search_str) if start_idx == -1: return 0, 0 end_idx = start_idx + len(search_str) return start_idx, end_idx - 1 ``` -------------------------------- ### AutoRAG Passage Filter Configuration Example Source: https://marker-inc-korea.github.io/AutoRAG/nodes/passage_filter/passage_filter An example `config.yaml` file illustrating the setup for a passage filter node in AutoRAG. It defines node lines, the passage filter node type, retrieval metrics, speed threshold, and the specific modules like `pass_passage_filter` and `similarity_threshold_cutoff` with their respective parameters. ```yaml node_lines: -node_line_name:retrieve_node_line# Arbitrary node line name nodes: -node_type:passage_filter strategy: metrics:[retrieval_f1,retrieval_recall,retrieval_precision] speed_threshold:5 modules: -module_type:pass_passage_filter -module_type:similarity_threshold_cutoff threshold:0.85 ``` -------------------------------- ### Run Pytest Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Executes the test suite for AutoRAG using pytest. The '-n auto' flag enables parallel test execution. ```bash python -m pytest -n auto ``` -------------------------------- ### Full AutoRAG YAML Configuration with Qdrant Source: https://marker-inc-korea.github.io/AutoRAG/integration/vectordb/qdrant This example demonstrates a more comprehensive AutoRAG configuration file, specifying Qdrant as the vector database and detailing retrieval and generation node setups. ```yaml vectordb: -name:openai_qdrant db_type:qdrant embedding_model:openai_embed_3_large collection_name:openai_embed_3_large client_type:docker embedding_batch:50 similarity_metric:cosine dimension:1536 node_lines: -node_line_name:retrieve_node_line# Arbitrary node line name nodes: -node_type:semantic_retrieval strategy: metrics:[retrieval_f1,retrieval_recall,retrieval_precision] top_k:3 modules: -module_type:vectordb vectordb:openai_qdrant -node_line_name:post_retrieve_node_line# Arbitrary node line name nodes: -node_type:prompt_maker strategy: metrics:[bleu,meteor,rouge] modules: -module_type:fstring prompt:"Readthepassagesandanswerthegivenquestion.\nQuestion:{query}\nPassage:{retrieved_contents}\nAnswer:" -node_type:generator strategy: metrics:[bleu,rouge] modules: -module_type:llama_index_llm llm:openai model:[gpt-4o-mini] ``` -------------------------------- ### Start Parsing Documents Source: https://marker-inc-korea.github.io/AutoRAG/data_creation/tutorial Initiates the parsing process for raw documents using a specified configuration file. The results are stored in a designated project directory. ```python from autorag.parser import Parser parser = Parser(data_path_glob="your/data/path/*", project_dir="./parse_project_dir") parser.start_parsing("your/path/to/parse_config.yaml") ``` -------------------------------- ### Configure Pytest for Environment Variables Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Sets up a pytest.ini file to define environment variables, such as OPENAI_API_KEY, for testing purposes. This ensures tests can access necessary credentials. ```ini [pytest] env = OPENAI_API_KEY=sk-...your-api-key... log_cli=true log_cli_level=INFO ``` -------------------------------- ### Run AutoRAG API Server via CLI Source: https://marker-inc-korea.github.io/AutoRAG/_sources/tutorial.md Launch the AutoRAG pipeline as an API server using the command-line interface. This method is convenient for quick deployments and allows specifying the trial directory, host, and port. ```bash autorag run_api --trial_dir /trial/dir/0 --host 0.0.0.0 --port 8000 ``` -------------------------------- ### Generator Node Configuration Example Source: https://marker-inc-korea.github.io/AutoRAG/nodes/generator/generator An example configuration file (config.yaml) demonstrating how to set up the Generator node. It specifies metrics for evaluation, LLM models to use, and parameters like batch size, speed threshold, and token threshold. ```yaml -node_line_name:post_retrieve_node_line# Arbitrary node line name nodes: -node_type:generator strategy: metrics: -metric_name:bleu -metric_name:meteor -metric_name:sem_score embedding_model:openai -metric_name:g_eval metrics:[consistency,fluency,relevance,coherence] model:gpt-4 -metric_name:bert_score lang:en batch:64 speed_threshold:10 token_threshold:4000 modules: -module_type:llama_index_llm llm:[openai] model:[gpt-3.5-turbo-16k,gpt-3.5-turbo-1106] temperature:[0.5,1.0,1.5] ``` -------------------------------- ### Build Docker Image for AutoRAG Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Builds a production-ready Docker image for AutoRAG. The `--target production` flag ensures only the production stage from the Dockerfile is used. ```docker docker build --target production -t autorag:prod . ``` -------------------------------- ### Start Parsing Process Source: https://marker-inc-korea.github.io/AutoRAG/data_creation/parse/parse Initiates the document parsing pipeline by calling the `start_parsing` method on the parser instance, passing the path to the configuration YAML file. ```python parser.start_parsing("your/path/to/parse_config.yaml") ``` -------------------------------- ### Set OpenAI API Key Environment Variable Source: https://marker-inc-korea.github.io/AutoRAG/_sources/install.md Configures the OPENAI_API_KEY environment variable, which is essential for using OpenAI models with AutoRAG. This can be done directly in the terminal. ```bash export OPENAI_API_KEY="sk-...your-api-key..." ```