Code Monkey home page Code Monkey logo

microsoft / rag-experiment-accelerator Goto Github PK

View Code? Open in Web Editor NEW
124.0 22.0 47.0 4.24 MB

The RAG Experiment Accelerator is a versatile tool designed to expedite and facilitate the process of conducting experiments and evaluations using Azure Cognitive Search and RAG pattern.

Home Page: https://github.com/microsoft/rag-experiment-accelerator

License: Other

Python 88.81% HTML 5.85% Dockerfile 0.06% Shell 0.21% Bicep 4.38% Makefile 0.69%
acs chunking embedding rag evaluation experiment information-retrieval openai azure genai

rag-experiment-accelerator's People

Contributors

adamdougal avatar algattik avatar anastasia-linzbach avatar auyidi1 avatar dburik avatar dependabot[bot] avatar eltociear avatar guybartal avatar jedheaj314 avatar jjgriff93 avatar joanassantos avatar joll59 avatar joshuaphelpsms avatar julia-meshcheryakova avatar kcortinas avatar kjeffc avatar lizashak avatar microsoftopensource avatar mohanajuhi166 avatar quovadim avatar rasavant-ms avatar raymond-nassar avatar ritesh-modi avatar ross-p-smith avatar shanepeckham avatar shivam-51 avatar superhindupur avatar tanya-borisova avatar tarockey avatar yuvalyaron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rag-experiment-accelerator's Issues

When running 02_qa_generation locally OPENAI_API_KEY and other ENV Variables are not available

Even when the .env is populated, the following error is raised when running 02_qa_generation.py locally

    from ingest_data.acs_ingest import generate_qna
  File "/Users/shanepeckham/sources/rag-experiment-accelerator/ingest_data/acs_ingest.py", line 9, in <module>
    from llm.prompt_execution import generate_response
  File "/Users/shanepeckham/sources/rag-experiment-accelerator/llm/prompt_execution.py", line 8, in <module>
    openai.api_key = os.environ['OPENAI_API_KEY']
  File "/Users/shanepeckham/opt/miniconda3/envs/rag-test/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'OPENAI_API_KEY'

Extend readme with more details for the first setup

Readme:
Replace
python -m pip install -r requirements.txt
with
python -m pip install -f requirements.txt

Shall we also note that on fresh machine it'll trigger error:
"Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools"

Minimal selection:

Under the "Workloads" tab, check the box for "Desktop development with C++."
Under the "Individual components" tab, make sure the following components are selected:
"Windows 10 SDK"
"MSVC v142 - VS 2019 C++ x64/x86 build tools"
"C++ ATL for latest v142 build tools (x86 & x64)"
"C++ MFC for latest v142 build tools (x86 & x64)"

Add test coverage to the core functions

Check existence of models on init openai

          You could also check existence of models at this stage. It can be done like this

from azure.core.exceptions import ResourceNotFoundError
from azure.ai.openai import OpenAIApiClient

client = OpenAIApiClient()

try:
deployment = client.deployments.get("your-deployment-name")
print("Deployment exists.")
except ResourceNotFoundError:
print("Deployment does not exist.")

Originally posted by @WVadim in #58 (comment)

Move OPENAI_EMBEDDING_DEPLOYED_MODEL to config

Currently OPENAI_EMBEDDING_DEPLOYED_MODEL is declared in .env file, while model used for chat completions is declared in config file. Anticipating more models in the future, it makes sense to move all model names into config under section "nlp_models" or something similar.

Action required: migrate or opt-out of migration to GitHub inside Microsoft

Migrate non-Open Source or non-External Collaboration repositories to GitHub inside Microsoft

In order to protect and secure Microsoft, private or internal repositories in GitHub for Open Source which are not related to open source projects or require collaboration with 3rd parties (customer, partners, etc.) must be migrated to GitHub inside Microsoft a.k.a GitHub Enterprise Cloud with Enterprise Managed User (GHEC EMU).

Action

โœ๏ธ Please RSVP to opt-in or opt-out of the migration to GitHub inside Microsoft.

โ—Only users with admin permission in the repository are allowed to respond. Failure to provide a response will result to your repository getting automatically archived.๐Ÿ”’

Instructions

Reply with a comment on this issue containing one of the following optin or optout command options below.

โœ… Opt-in to migrate

@gimsvc optin --date <target_migration_date in mm-dd-yyyy format>

Example: @gimsvc optin --date 03-15-2023

OR

โŒ Opt-out of migration

@gimsvc optout --reason <staging|collaboration|delete|other>

Example: @gimsvc optout --reason staging

Options:

  • staging : This repository will ship as Open Source or go public
  • collaboration : Used for external or 3rd party collaboration with customers, partners, suppliers, etc.
  • delete : This repository will be deleted because it is no longer needed.
  • other : Other reasons not specified

Need more help? ๐Ÿ–๏ธ

Replace prints with proper logging

Tasks

Validate existence of models and keys

We should validate existence of all models and keys required for a particular step before executing the step. At the moment, in step 01_Index.py of model chat_model_name does not exist, we will build a bunch of embeddings only to fail at the last line of the script.
This logic should also be propagated to other scripts, in order to save user's resources and time

Prompt Engineering within the RAG Pattern

Should include prompt templates within the RAG Experiment Accelerator to allow the user to experiment.
Current prompt templates are located in llm\prompts.py

Tasks

  1. rasavant-ms raymond-nassar
  2. enhancement
    rasavant-ms
  3. rasavant-ms

Add some instructions in readme to let customers know they should add pdfs in data folder then run 01_Index.py?

I encountered such error when running 01_Index.py file following the guidance in readme.md. After some debugging, I figured out it is because the data folder is empty.
Can you pls add some instructions in readme to let customers know they should add pdfs in data folder then run 01_index.py?

Traceback (most recent call last):
File "C:\Users\yijunzhang\Documents\code_repo\rag-experiment-accelerator\01_Index.py", line 72, in
upload_data(data_load,service_endpoint,index_name,key, dimension, chat_model_name, temperature)
File "C:\Users\yijunzhang\Documents\code_repo\rag-experiment-accelerator\ingest_data\acs_ingest.py", line 46, in upload_data
results = search_client.upload_documents(documents)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yijunzhang\Anaconda3\envs\fhl\Lib\site-packages\azure\search\documents_search_client.py", line 543, in upload_documents
results = self.index_documents(batch, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yijunzhang\Anaconda3\envs\fhl\Lib\site-packages\azure\core\tracing\decorator.py", line 76, in wrapper_use_tracer
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yijunzhang\Anaconda3\envs\fhl\Lib\site-packages\azure\search\documents_search_client.py", line 641, in index_documents
return self._index_documents_actions(actions=batch.actions, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yijunzhang\Anaconda3\envs\fhl\Lib\site-packages\azure\search\documents_search_client.py", line 649, in _index_documents_actions
batch_response = self._client.documents.index(batch=batch, error_map=error_map, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yijunzhang\Anaconda3\envs\fhl\Lib\site-packages\azure\core\tracing\decorator.py", line 76, in wrapper_use_tracer
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yijunzhang\Anaconda3\envs\fhl\Lib\site-packages\azure\search\documents_generated\operations_documents_operations.py", line 1264, in index
raise HttpResponseError(response=response, model=error)
azure.core.exceptions.HttpResponseError: (MissingRequiredParameter) The request is invalid. Details: actions : No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request.
Code: MissingRequiredParameter
Message: The request is invalid. Details: actions : No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request.
Exception Details: (MissingIndexDocumentsActions) No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request. Parameters: actions
Code: MissingIndexDocumentsActions
Message: No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request. Parameters: actions

Support OpenAI models directly

The Accelerator currently supports models from Azure, but we should allow access to models provided directly from OpenAI.

Augmentation of ingested data

Current implementation captures the "title" and "summary", will need to include keywords, keyphrases, and entities. Need to edit the prompts.py and acs_ingest.py files to request that the LLM generate keywords and entities.

RAG Pattern for Multi-Lingual Scenarios

Azure Cognitive Search has skillsets for language detection/processing. Exploration will be required to determine the best implementation. Should experiment with German, Italian, and English as languages to be tested, as these are currently being used in an active customer engagement.

Tasks

Enable Prompt-like Interaction with the Accelerator

Interactive tool which helps user choose intent, query type, understand their data and possible label sets, focus on different relevant parts of the documents to generate different results to help user choose what makes most sense.

Can be summarized as content understanding and intent understanding:

  • Understanding source of data, potential sources of data and type of data
  • Leveraging CMS sources including metadata
  • Questions to identify what content processing would work best
  • Questions to identify intent - Comparison intent, search intent, opinion intent

QA generation - JSON not valid bug

Currently running the 02_qa_generation.py sometimes provides an invalid JSON output.
Update or fix the QA generation prompt in prompts.py to make sure that only a valid JSON is created as a result of running the 02_qa_generation.py script.

Load Documents into the Accelerator in parallel

Parallel jobs need to be enabled within the Accelerator to accept the ingestion and processing of multiple documents/artifacts.

Potential pattern to be applied would be via the implementation of Azure Machine Learning pipelines.

Tasks

No tasks being tracked yet.

Make conda environment file and add versions

Currently we are expecting some version of python and fixed versions of libraries, but do not specify it anywhere except README.
What could be done, is to create environment.yaml for conda, to automatically create conda env with everything required, including preloaded models and versioned libraries as well as specify python version

Remove PII from Git commit history

For example, the eval_data.jsonl file has PII (emails, phone numbers, job titles, etc.) related to personnel who work for a customer. All files need to be scanned for PII and sanitized.

Implement Azure OpenAI Embeddings Models

Create a config file associated with the generate_embeddings.py file that can provide the appropriate sizes and chunks for Azure OpenAI embeddings models.

The definition for embedding_dimension should be automatically mapped to the selected embeddings model.

Also update documentation with the relevant instructions for users.

Background:
Azure Open AI offers embeddings that can be used to do search and analyze complex documents. Some examples of complex documents are:

  • Legal contracts
  • Medical records
  • Scientific articles

Embeddings are numerical representations of words and phrases that capture the meaning and context of the text. These embeddings can be used to build powerful search and analysis tools that can extract insights from large volumes of text data.

Everything should be linked to the search configuration.

https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/understand-embeddings

Documentation on "Task-specific knowledge enrichment" can assist in the implementation of embeddings models.

Documentation

Add documentation to explain:

Tasks

  1. documentation
    kjeffc
  2. documentation
    Joll59
  3. documentation
  4. documentation
    julia-meshcheryakova
  5. documentation
    raymond-nassar
  6. documentation
    joshuaphelpsms

Implement Search Evaluator while querying

Need to evaluate the search response from Azure Cognitive Search to determine its information retrieval accuracy. A score for response relevancy should be included as part of the tooling for this section.

https://learn.microsoft.com/en-us/azure/search/search-pagination-page-layout

https://learn.microsoft.com/en-us/azure/search/index-similarity-and-scoring

Search metrics that should be included:

  • precision@k
  • recall@k
  • map@k

Tasks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.