Coder Social home page Coder Social logo

Comments (4)

lofti198 avatar lofti198 commented on June 29, 2024 1

Oh great! Thank you for your cool hint on onnx!

from higlabo.

higty avatar higty commented on June 29, 2024

Please see ChatCompletionStreamWithUsageResult method in OpenAIPlayground.cs file.
GetUsageResult method is key method.

var p = new ChatCompletionsParameter();
p.AddUserMessage($"How to enjoy coffee");
p.Model = "gpt-4o";
p.Stream_Options = new
{
    include_usage = true,
};

var result = new ChatCompletionStreamResult();
await foreach (string text in cl.ChatCompletionsStreamAsync(p, result, CancellationToken.None))
{
    Console.Write(text);
}
Console.WriteLine();
Console.WriteLine();

var usage = result.GetUsageResult();
if (usage != null)
{
    Console.WriteLine("------------------------");
    Console.WriteLine("Prompt tokne: " + usage.Prompt_Tokens);
    Console.WriteLine("Completion tokne: " + usage.Completion_Tokens);
    Console.WriteLine("Total tokne: " + usage.Total_Tokens);
}

from higlabo.

lofti198 avatar lofti198 commented on June 29, 2024

Thank you! It works awesome as always. By the way, have you research the question of price optimisation of image recognition? For example I have pretty typical documents which I recognize with gpt-o4 model. It costs usually like this:
Prompt token: 1117
Completion token: 228
Total tokne: 1345

Which way would you suggest me to go to optimise it? I guess training own image to text model (for typical layouts) is the best way?

from higlabo.

higty avatar higty commented on June 29, 2024

The best way to reduce price is to use local LLM.
You can get various model on HuggingFace and you can use it by ONNX from C#.
I think that LLM will be more intelligence in this year, so it it worth to watch.

from higlabo.

Related Issues (20)

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.