-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: getting started #589
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
edb40f1
docs: getting started
jjmachan d5cd524
fix headings
jjmachan 17c1992
fixed with gpt4
jjmachan d21a03e
monitoring
jjmachan c6f49df
evaluations
jjmachan 2a3bf68
testset
jjmachan c5151dd
Merge branch 'main' into docs/full
jjmachan 9780656
added emojies
jjmachan 7507067
fix autoreload
jjmachan ce8f973
fix reload
jjmachan 7890762
fixed docs with review
jjmachan e057a91
fix feedback from rewview with gpt4
jjmachan 1464cd7
fix extra note
jjmachan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from collections import namedtuple | ||
import asyncio | ||
from tqdm.asyncio import tqdm | ||
import typing as t | ||
from langchain_openai.chat_models import ChatOpenAI | ||
from langchain_core.language_models.chat_models import BaseChatModel | ||
from langchain.prompts import ChatPromptTemplate | ||
|
||
File = namedtuple("File", "name content") | ||
|
||
|
||
def get_files(path: str, ext: str) -> list: | ||
return [os.path.join(path, f) for f in os.listdir(path) if f.endswith(ext)] | ||
|
||
|
||
def load_docs(path: str) -> t.List[File]: | ||
files = [*get_files(path, ".md")] | ||
docs = [] | ||
for file in files: | ||
with open(file, "r") as f: | ||
docs.append(File(file, f.read())) | ||
return docs | ||
|
||
|
||
async def fix_doc_with_llm(doc: File, llm: BaseChatModel) -> File: | ||
prompt = """\ | ||
fix the following grammar and spelling mistakes in the following text. | ||
Please keep the markdown format intact when reformating it. | ||
Do not make any change to the parts of text that are for formating or additional metadata for the core text in markdown. | ||
The target audience for this is developers so keep the tone serious and to the point without any marketing terms. | ||
The output text should me in .md format. | ||
|
||
text: {text} | ||
""" | ||
fix_docs_prompt = ChatPromptTemplate.from_messages( | ||
[ | ||
(prompt), | ||
] | ||
) | ||
# get output | ||
fixed_doc = await llm.ainvoke(fix_docs_prompt.format_messages(text=doc.content)) | ||
return File(doc.name, fixed_doc.content) | ||
|
||
|
||
async def main(docs: t.List[File], llm: BaseChatModel): | ||
fix_doc_routines = [fix_doc_with_llm(doc, llm) for doc in docs] | ||
return await tqdm.gather(*fix_doc_routines) | ||
|
||
|
||
if __name__ == "__main__": | ||
""" | ||
Helpful assistant for documentation review and more (hopefully in the future). | ||
""" | ||
gpt4 = ChatOpenAI(model="gpt-4") | ||
docs = load_docs("./getstarted/") | ||
fix_docs = asyncio.run(main(docs, gpt4)) | ||
for doc in fix_docs: | ||
with open(doc.name, "w") as f: | ||
f.write(doc.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(core-concepts)= | ||
# Core Concepts | ||
# 📚 Core Concepts | ||
:::{toctree} | ||
:caption: Concepts | ||
:hidden: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,44 @@ | ||
(get-started)= | ||
# Get Started | ||
# 🚀 Get Started | ||
|
||
:::{toctree} | ||
:maxdepth: 1 | ||
:hidden: | ||
install.md | ||
evaluation.md | ||
testset_generation.md | ||
evaluation.md | ||
monitoring.md | ||
::: | ||
|
||
Welcome to the Ragas tutorials! These beginner-friendly tutorials will guide you | ||
through the fundamentals of working with Ragas. These tutorials do assume basic | ||
knowledge of Python and Retrieval Augmented Generation (RAG) pipelines. | ||
Welcome to the Ragas tutorials! If you're new to Ragas, the Get Started guides will walk you through the fundamentals of working with Ragas. These tutorials assume basic knowledge of Python and Retrieval Augmented Generation (RAG) pipelines. | ||
|
||
Before you go further make sure you have [Ragas installed](./install.md)! | ||
Before you proceed further, ensure that you have [Ragas installed](./install.md)! | ||
|
||
:::{note} | ||
The tutorials only give you on overview of what you can do with ragas and the | ||
basic skill you need to use it. If you want an in-depth explanation of the | ||
core-concepts behind Ragas, check out the [Core Concepts](../concepts/index.md) page. You can also checkout the [How-to Guides](../howtos/index.md) if you want to specific applications of Ragas. | ||
The tutorials only provide an overview of what you can accomplish with Ragas and the basic skills needed to utilize it effectively. For an in-depth explanation of the core concepts behind Ragas, check out the [Core Concepts](../concepts/index.md) page. You can also explore the [How-to Guides](../howtos/index.md) for specific applications of Ragas. | ||
::: | ||
|
||
If you have any questions about Ragas, feel free to join and ask in the `#questions` channel in our Discord community. | ||
|
||
If you have any questions about Ragas, feel free to join and ask in the | ||
`#questions` channel in our discord community ❤ . | ||
|
||
Let’s get started! 🏁 | ||
Let's get started! | ||
|
||
:::{card} Ragas Metrics and Evaluation | ||
:link: get-started-evaluation | ||
:::{card} Generate a Synthetic Testset | ||
:link: get-started-testset-generation | ||
:link-type: ref | ||
|
||
How to use the Ragas Metrics to evaluate your RAG pipelines. | ||
Learn how to generate `Question/Context/Ground_Truth` triplets to get started. | ||
::: | ||
|
||
:::{card} Synthetic Test data Generation | ||
:link: get-started-testset-generation | ||
:::{card} Evaluate Using Your Testset | ||
:link: get-started-evaluation | ||
:link-type: ref | ||
|
||
How to generate test set to assess your RAG pipelines | ||
Find out how to evaluate your RAG pipeline using your test set (your own dataset or synthetic). | ||
::: | ||
:::{card} Monitoring | ||
|
||
:::{card} Monitor Your RAG in Production | ||
:link: get-started-monitoring | ||
:link-type: ref | ||
|
||
How to monitor your RAG systems in production. | ||
::: | ||
Discover how to monitor the performance and quality of your RAG application in production. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
# Install | ||
# Installation | ||
|
||
To get started, install Ragas using `pip` with the following command: | ||
|
||
You can install ragas with | ||
```bash | ||
pip install ragas | ||
``` | ||
|
||
If you want to install the latest version (from the main branch) | ||
If you'd like to experiment with the latest features, install the most recent version from the main branch: | ||
|
||
```bash | ||
pip install git+https://github.com/explodinggradients/ragas.git | ||
``` | ||
|
||
If you are looking to contribute and make changes to the code, make sure you | ||
clone the repo and install it as [editable | ||
install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs). | ||
If you're planning to contribute and make modifications to the code, ensure that you clone the repository and set it up as an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs). | ||
|
||
```bash | ||
git clone https://github.com/explodinggradients/ragas.git | ||
cd ragas | ||
pip install -e . | ||
``` | ||
|
||
Next, let's construct a [synthetic test set](get-started-testset-generation) using your own data. If you've brought your own test set, you can learn how to [evaluate it](get-started-evaluation) using Ragas. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
(get-started-monitoring)= | ||
# Monitoring | ||
# Monitor Your RAG in Production | ||
|
||
Maintaining the quality and performance of an LLM application in a production environment can be challenging. Ragas provides with basic building blocks that you can use for production quality monitoring, offering valuable insights into your application's performance. This is achieved by constructing custom, smaller, more cost-effective, and faster models. | ||
Maintaining the quality and performance of a RAG application in a production environment is challenging. RAG currently provides the essential building blocks for production-quality monitoring, offering valuable insights into your application's performance. However, we are also working towards building a more advanced production monitoring solution by addressing three key areas: | ||
|
||
1. How to ensure the distribution of your production dataset remains consistent with your test set. | ||
2. How to effectively extract insights from the explicit and implicit signals your users provide to infer the quality of your RAG application and identify areas that require attention. | ||
3. How to construct custom, smaller, more cost-effective, and faster models for evaluation and advanced test set generation. | ||
|
||
:::{note} | ||
This is feature is still in beta access. You can requests for | ||
[**early access**](https://calendly.com/shahules/30min) to try it out. | ||
We are still developing and gathering feedback for upcoming releases. You can request | ||
[**early access**](https://calendly.com/shahules/30min) to try it out or share the challenges you face in this area. We would love to hear your thoughts and challenges. | ||
::: | ||
|
||
The Ragas metrics can also be used with other LLM observability tools like | ||
[Langsmith](https://www.langchain.com/langsmith) and | ||
[Langfuse](https://langfuse.com/) to get model-based feedback about various | ||
aspects of you application like those mentioned below | ||
In addition, you can use the RAG metrics with other LLM observability tools like: | ||
|
||
:::{seealso} | ||
[Langfuse Integration](../howtos/integrations/langfuse.ipynb) to see Ragas | ||
monitoring in action within the Langfuse dashboard and how to set it up | ||
::: | ||
- [Langsmith](../howtos/integrations/langsmith.ipynb) | ||
- [Phoenix (Arize)](../howtos/integrations/ragas-arize.ipynb) | ||
- [Langfuse](../howtos/integrations/langfuse.ipynb) | ||
- [OpenLayer](https://openlayer.com/) | ||
|
||
These tools can provide model-based feedback about various aspects of your application, such as the ones mentioned below: | ||
|
||
## Aspects to Monitor | ||
|
||
1. Faithfulness: This feature assists in identifying and quantifying instances of hallucinations. | ||
2. Bad retrieval: This feature helps identify and quantify poor context retrievals. | ||
3. Bad response: This feature helps in recognizing and quantifying evasive, harmful, or toxic responses. | ||
4. Bad format: This feature helps in detecting and quantifying responses with incorrect formatting. | ||
5. Custom use-case: For monitoring other critical aspects that are specific to your use case. [Talk to founders](https://calendly.com/shahules/30min) | ||
1. Faithfulness: This feature assists in identifying and quantifying instances of hallucination. | ||
2. Bad Retrieval: This feature helps identify and quantify poor context retrievals. | ||
3. Bad Response: This feature assists in recognizing and quantifying evasive, harmful, or toxic responses. | ||
4. Bad Format: This feature enables the detection and quantification of responses with incorrect formatting. | ||
5. Custom Use-Case: For monitoring other critical aspects that are specific to your use-case, [Talk to the founders](https://calendly.com/shahules/30min). | ||
|
||
Note: | ||
- "Evaluate your test set" has been replaced with "Evaluate using your test set" to clarify that the evaluation is conducted using the test set, not on the quality of the test set itself. | ||
- Phrases such as "How can we" have been replaced with "How to" to make the content more direct and actionable. | ||
- The term "Answer using synthetic data generation" has been replaced with "Question/Context/Ground Truth triplets". |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a script that helps review docs too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that gpt4 actually helps a lot in keeping the tone professional and consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I don't think the prompt is proper - can be improved