Skip to content

Commit

Permalink
Update docs (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
svilupp committed Apr 30, 2024
1 parent 940233f commit 7ecb0d9
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 68 deletions.
Binary file added docs/src/assets/makie2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/tidier1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/tidier2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 79 additions & 68 deletions docs/src/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,89 +51,100 @@ All setup should take less than 5 minutes!

## Quick Start Guide

1. **Basic Usage**:
```julia
using AIHelpMe
aihelp("How do I implement quicksort in Julia?")
```

```plaintext
[ Info: Done generating response. Total cost: \$0.015
AIMessage("To implement quicksort in Julia, you can use the `sort` function with the `alg=QuickSort` argument.")
1) **Basic Usage**:
```julia
using AIHelpMe
aihelp("How do I implement quicksort in Julia?")
```

Note: As a default, we load only the Julia documentation and docstrings for standard libraries. The default model used is GPT-4 Turbo.
```plaintext
[ Info: Done generating response. Total cost: \$0.015
AIMessage("To implement quicksort in Julia, you can use the `sort` function with the `alg=QuickSort` argument.")
```

You can pretty-print the answer using `pprint` if you return the full RAGResult (`return_all=true`):
```julia
using AIHelpMe: pprint
Note: As a default, we load only the Julia documentation and docstrings for standard libraries. The default model used is GPT-4 Turbo.

result = aihelp("How do I implement quicksort in Julia?", return_all=true)
pprint(result)
```
You can pretty-print the answer using `pprint` if you return the full RAGResult (`return_all=true`). If displayed in REPL, it will use color highlights as well (magenta color = text not from the "context").
```julia
using AIHelpMe: pprint
```plaintext
--------------------
QUESTION(s)
--------------------
- How do I implement quicksort in Julia?
--------------------
ANSWER
--------------------
To implement quicksort in Julia, you can use the [5,1.0]`sort`[1,1.0] function with the [1,1.0]`alg=QuickSort`[1,1.0] argument.[2,1.0]
--------------------
SOURCES
--------------------
1. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions
2. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions
3. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Algorithms
4. SortingAlgorithms::/README.md::0::SortingAlgorithms
5. AIHelpMe::/README.md::0::AIHelpMe
```
result = aihelp("How do I implement quicksort in Julia?", return_all=true)
pprint(result)
```

Note: You can see the model cheated because it can see this very documentation...
```plaintext
--------------------
QUESTION(s)
--------------------
- How do I implement quicksort in Julia?
--------------------
ANSWER
--------------------
To implement quicksort in Julia, you can use the [5,1.0]`sort`[1,1.0] function with the [1,1.0]`alg=QuickSort`[1,1.0] argument.[2,1.0]
--------------------
SOURCES
--------------------
1. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions
2. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions
3. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Algorithms
4. SortingAlgorithms::/README.md::0::SortingAlgorithms
5. AIHelpMe::/README.md::0::AIHelpMe
```

2. **`aihelp` Macro**:
```julia
aihelp"how to implement quicksort in Julia?"
```
Note: You can see the model cheated because it can see this very documentation...

3. **Follow-up Questions**:
```julia
aihelp!"Can you elaborate on the `sort` function?"
```
Note: The `!` is required for follow-up questions.
`aihelp!` does not add new context/more information - to do that, you need to ask a new question.
Note 2: The square brackets represent the corresponding source and the strength of association (1.0 is the highest), eg, `[1,1.0]` indicates high confidence in the sentences having high overlap with the chunk in source #1.

4. **Pick faster models**:
Eg, for simple questions, GPT 3.5 might be enough, so use the alias "gpt3t":
```julia
aihelp"Elaborate on the `sort` function and quicksort algorithm"gpt3t
```
2) **`aihelp` Macro**:
```julia
aihelp"how to implement quicksort in Julia?"
```

```plaintext
[ Info: Done generating response. Total cost: \$0.002 -->
AIMessage("The `sort` function in programming languages, including Julia.... continues for a while!
```
3) **Follow-up Questions**:
```julia
aihelp!"Can you elaborate on the `sort` function?"
```
Note: The `!` is required for follow-up questions.
`aihelp!` does not add new context/more information - to do that, you need to ask a new question.

4) **Pick faster models**:
Eg, for simple questions, GPT 3.5 might be enough, so use the alias "gpt3t":
```julia
aihelp"Elaborate on the `sort` function and quicksort algorithm"gpt3t
```

```plaintext
[ Info: Done generating response. Total cost: \$0.002 -->
AIMessage("The `sort` function in programming languages, including Julia.... continues for a while!
```

5. **Debugging**:
How did you come up with that answer? Check the "context" provided to the AI model (ie, the documentation snippets that were used to generate the answer):
```julia
using AIHelpMe: pprint, last_result
pprint(last_result())
# Output: Pretty-printed Question + Context + Answer with color highlights
```
How did you come up with that answer? Check the "context" provided to the AI model (ie, the documentation snippets that were used to generate the answer):
```julia
using AIHelpMe: pprint, last_result
pprint(last_result())
# Output: Pretty-printed Question + Context + Answer with color highlights
```

The color highlights show you which words were NOT supported by the provided context (magenta = completely new, blue = partially new).
It's an intuitive way to see which function names or variables are made up versus which ones were in the context.
Examples of the highlighted output:

You can change the kwargs of `pprint` to hide the annotations or potentially even show the underlying context (snippets from the documentation):
![Highlighted output #1](assets/tidier2.png)

![Highlighted output #2](assets/makie2.png)

The color highlights show you which words were NOT supported by the provided context (magenta = completely new, blue = partially new).
It's an intuitive way to see which function names or variables are made up versus which ones were in the context.

The square brackets represent the corresponding source and the strength of association (1.0 is the highest), eg, `[1,1.0]` indicates high confidence in the sentences having high overlap with the chunk in source #1.

You can change the kwargs of `pprint` to hide the annotations or potentially even show the underlying context (snippets from the documentation):

```julia
pprint(last_result(); add_context = true, add_scores = false)
```

```julia
pprint(last_result(); add_context = true, add_scores = false)
```

> [!TIP]
> Your results will significantly improve if you enable re-ranking of the context to be provided to the model (eg, `aihelp(..., rerank=true)`) or change pipeline to `update_pipeline!(:silver)`. It requires setting up Cohere API key but it's free for community use.
Expand Down

0 comments on commit 7ecb0d9

Please sign in to comment.