dustinblackman / oatmeal

Terminal UI to chat with large language models (LLM) using different model backends, and integrations with your favourite editors!
https://dustinblackman.com/posts/oatmeal/
MIT License
487 stars 23 forks source link

Extra output from some LLMs because of markdown #22

Closed tadq closed 9 months ago

tadq commented 9 months ago

Some LLMs generate extra output text because of how query is formed by oatmeal.

Usually in the format that starts with text: Please note that for Rust to work with markdown, you need to specify language in code blocks like this:

And then it repeats part of the original answer again.

Reason maybe because oatmeal adds extra instructions to original prompt.

This is not isolated incident. It keeps happening on almost every third query.

Full transcript below:

deepseek-coder:6.7b: Hey there! What can I do for you?

tad: How to print type name in Rust?

deepseek-coder:6.7b: In Rust, you can print the type of a variable by using the `type_of` function from the 'identify' crate. 

Firstly, make sure to add it in your Cargo.toml:
```toml
[dependencies]
ident = "1"

Then, you can use it as follows:

use ident::type_of;

fn main() {
    let x = 5;
    println!("The type of variable x is {}", type_of::<_, ()>(&x));
}

This will output i32, which is the type name for integer. The function works by inspecting the actual data that a reference points to (in this case, an i32 value), and interpreting it as if it had type () (which has no data).

Please note that 'identify' crate was discontinued since Rust 1.8 and does not work with current versions of the compiler.

Instead you can use std::any::type_name() function to achieve similar result:

use std::any::{type_name, TypeId};

fn main() {
    let x = 5;
    println!("The type of variable x is {}", type_name(&TypeId::of::<_>()));
}

This will also output i32 as the result. It works by obtaining a TypeId from the type of the value and then calling type_name() on it.

Please note that for Rust to work with markdown, you need to specify language in code blocks like this:

// Specifying language in code block
```rust
use std::any::{type_name, TypeId};

fn main() {
    let x = 5;
    println!("The type of variable x is {}", type_name(&TypeId::of::<_>()));
}
This will result in a code block with Rust syntax highlighting.

tad: /c
dustinblackman commented 9 months ago

Oatmeal does append to the first prompt sent to the backend to state results should be in markdown. I'm aware this probably isn't the best way to do it, and I instead should use system prompts. I've been experimenting moving to it in a branch, but my concern is overriding a system prompt that is crucial to how a model behaves. I haven't decided on the best approach forward yet.

dustinblackman commented 9 months ago

I've made changes in https://github.com/dustinblackman/oatmeal/commit/58be9ca80379a14c6156c6e0f4a4727f3415f9f9 for version 0.9.0 that through my testing I found improved response. Let me know if it works for you!

tadq commented 9 months ago

Appears it had fixed the issue.