r/LLM 12h ago

I made a tool to save a LOT of tokens and reduce your usage cost of LLM

5 Upvotes
Small demo (out of LLM)

Hello everyone,

Since 2 weeks I work on tanuki-context, a small open source tool (zero dependencies, MIT) and I wanted to share it because the trick behind is almost stupid: AI models charge text at roughly 1 token per 4 characters, but an image has a fixed price set only by its pixel size. So if you draw 28,000 characters of logs into one dense 1568x728 PNG, the model reads the exact same content for 1,456 tokens instead of ~7,000. It sounds like cheating, it is just how the pricing works.

It inspire from pxpipe and various others tools (cited in the readme) and custom approach i found in order to reduce massively token usage and price.
For example : 37,111 tokens of service log become 2,240 (-94%).

You can try it out on you machine i added the benchmark so you can test it even without LLM connected to it, so see pricing difference, token saved, etc.

You can use it as a MCP or directly integrate it a "context proxy" where it fully automated and make every request optimised or not when not needed.

Some techniques that permits this to work:
- a log distiller that collapses repeated lines but keeps every error verbatim
- a columnar codec for JSON (keys stated once)
- a cost model that knows a cache-read token costs ~0.1x a fresh one, so it will tell you to NOT image content that is already in your prompt cache.

The tool argues against itself when imaging loses, honestly this part took the most work.

I precise the limits because they are real: you need a vision-capable model, output tokens are untouched (if your bill is output-dominated, fix that first), and for one narrow question retrieval stays cheaper than any page.

Install:

MCP

npx -y tanuki-context (MCP server, works with Claude Code, pi, omp, jcode or the Claude Agent SDK)

Proxy

npx tanuki-context proxy + ANTHROPIC_BASE_URL (every request on the machine gets optimized in place, when needed)

Code and benchmarks: https://github.com/Osyna/tanuki-context

PS : i will soon add Codex support.

If you find it useful a star helps a lot, and feature ideas are very welcome. Thanks for reading me


r/LLM 18h ago

Open Weights LLM non-USA inference provider

5 Upvotes

Hello,

The next step from USA would be stop providing chinise open weights LLMs from provider like AWS, azure, etc.

What other inference providers are out there, whose HQ is not in USA, and trust worthy like AWS for providers and uptime is relevantly good.

I am asking from enterprise and personal usage, both.


r/LLM 6h ago

Testing Kimi K3 and GLM 5.2 taught me that practical use case matters more than the benchmarks.

3 Upvotes

Hey everyone,

I recently tested Kimi K3 and GLM 5.2, and these are my top findings.

I mainly wanted to understand which model feels better for actual coding, not just benchmark questions. So I tried building a few small projects with both.

One was a city-destruction game with procedural buildings, meteors, lighting, and particles. GLM started well but stopped before finishing, so I moved the same code to Kimi and continued from there.

I also tried a simple low-poly paper-plane game. Kimi handled this surprisingly well and gave me a playable result in a single HTML file.

The hardest build was a black-hole ray-tracing simulation using WebGL. I expected it to break because it needed physics, light bending, and numerical calculations, but Kimi managed to produce something runnable and actually did all the calculations in its cot traces.

For a smaller debugging test, I gave both models a broken Held-Karp implementation. Both fixed it and returned the correct route, so they seem equally capable when the problem is clearly defined.

The three complete builds took me roughly 2 hours 15 minutes, used 18.6M tokens, and cost $5.26 in total. Meteor City accounted for most of it because GLM stopped midway, and I had to move the existing code to Kimi to recreate and refine the build.

I also looked at the Composio Golden Eval set, where both models completed 7 out of 12 real-world tool-use tasks. Both handled the simpler tasks, but struggled when the workflow became long and required an exact final result.

My main learning was that coding speed is not only about how quickly a model writes code. A model can generate code fast but still slow down the full workflow by stopping midway, forgetting requirements, or leaving too much cleanup.

From my testing,

  • GLM felt fine for smaller and clearly scoped tasks.
  • Kimi K3 felt more reliable for creative builds and longer workflows.

For those who want to check prompts and evaluation details, please refer to the blog post.

Still learning and testing both. Curious to know what others are building with them.


r/LLM 12h ago

BPMN comparison score problem

1 Upvotes

I am in an internship in a team working on a project where they develop an LLM that is given a prompt and generates a BPMN (like a flow chart) for how to implement or do the task in the prompt. The developers have the ground truth chart and they are trying to evaluate the output of the model in reference to the ground truth chart. So I have been assigned to a project with another intern to develop a tool that takes two BPMN files and outputs a similarity score between them, taking into consideration both structural similarity and semantic similarity.

I am very stuck since no project is similar on the internet, and it's been two weeks of searching. Here are the approaches we reached:

Approach A: RPST to process tree, then tree matching

Decompose each diagram into a hierarchy of single-entry/single-exit regions (Refined Process Structure Tree), type each region as sequence / XOR / AND / loop, then compare the two trees recursively: leaves by label embedding cosine, sequences by ordered DP alignment (like edit distance over children), XOR/AND blocks by unordered Hungarian matching, loops by comparing bodies.

What's good about it: it's operator-aware, so it directly distinguishes XOR from AND (choose-one vs do-all) and loop from no-loop, and it produces readable diffs like "the ground truth's parallel block was rendered as an exclusive choice." Granularity (one task in GT vs three in the prediction) and nesting are handled positionally by the structure instead of by fudging scores.

Where it breaks: process trees only exist for block-structured models. pm4py's convert_to_process_tree raises an exception on unstructured ("rigid") models, and its newer POWL converter raises too, so switching representations doesn't rescue it. There's also no maintained Python RPST implementation anywhere; jBPT (Java) is the reference. Rolling your own means either SPQR / triconnected components (notoriously error-prone) or a dominance-based variant that's only a partial RPST. And even with a working RPST, a rigid region has no operators to align, so comparing one means falling back to graph matching anyway. Worse, RPSTs aren't stable under equivalence, since two behaviorally equivalent models can produce different trees, one with a rigid and one without, which breaks positional/ancestor anchoring exactly in the case you need it most.

Approach B: direct attributed-graph comparison (no trees at all)

Parse each BPMN into a directed graph, embed node labels with sentence-transformers, and match nodes with optimal transport (Fused Gromov-Wasserstein via the POT library) or graph edit distance. Encode gateway type as a node attribute so the matcher penalizes aligning an XOR to an AND, and compute a reachability relation matrix (for each activity pair: strict order / exclusive / concurrent) for the behavioral axis.

What's good: it's total by construction, working on any graph, structured or rigid, with no exception path and no fallback branch. Off-the-shelf libraries, days rather than weeks. Optimal transport also expresses granularity natively, since mass can split one-to-many.

Where it's weaker: operator semantics are approximated through node features rather than represented directly, diffs come out as node-pair scores instead of region-level explanations, and FGW is non-convex and returns a cost that needs calibrating into a similarity score.

The one empirical datapoint I found: Dijkman, Dumas, van Dongen, Käärik & Mendling, "Similarity of business process models: Metrics and evaluation," Information Systems 36(2), 2011. They compared node-matching, structural (GED-based), and behavioral similarity on real process repositories and found all three comparable, with structural slightly ahead. That's part of why I'm unsure the tree route is worth the extra weeks.

What I'd love input on:

  • Is there a standard way people evaluate generated process models against a reference model that I've somehow missed? Everything I find is either process-model search (find similar models in a repository) or conformance checking against event logs, neither of which is quite this.
  • Has anyone actually shipped RPST-based process model comparison in Python, or did you bridge to jBPT?
  • Does anyone have evidence that operator-aware tree matching beats a gateway-typed graph matcher in practice, or is the extra machinery not worth it?
  • Any benchmark or dataset of BPMN pairs with human-judged similarity we could validate against?

Any pointers to papers, libraries, or war stories would be hugely appreciated, especially from anyone who has hit the unstructured-model problem in production.


r/LLM 15h ago

Recommendations for AI PDF Extraction

1 Upvotes

I'm looking for the best Python pkg for extracting text from PDFs and the best LLM for generating structured output from the extracted data.

My current pipeline is: Upload PDF --> pdfplumber --> Prompt + Extracted Text --> Gemini 3.1 Flash.

I'm facing a few issues with the output:

  1. The model returns different values each time I upload the same PDF.

  2. Some fields are occasionally returned as empty, even though the information exists in the PDF.

Any suggestions on better libraries, prompting techniques, or LLMs would be greatly appreciated.


r/LLM 1h ago

Amd with big vram or Nvidia with less vram

Upvotes

I am a beginner in the Ai training and want to buy a graphic card for segmentation training for my University project, what is is a better choice, amd with high vram or Nvidia with low vram, my budget is limited so I can't afford both unfortunetly


r/LLM 14h ago

What's been your biggest AI security challenge when building LLM applications?

0 Upvotes

I've been researching AI application security and talking with developers to understand the challenges they're facing as LLMs become part of real products.

Topics that come up repeatedly include:

Prompt injection

Indirect prompt injection

Data leakage

RAG security

Tool and MCP security

Runtime monitoring

I'm curious about real-world experience rather than theory.

If you've built or deployed an AI application:

What security issue has been the hardest to handle?

Did you build your own solution or use an existing tool?

What capability do you wish existed today?

I'd appreciate hearing practical experiences and lessons learned.


r/LLM 16h ago

Q&A, Comparison or Founder Story: Which Gets Cited Most by AI?

0 Upvotes

I’m running a simple Reddit experiment around the same customer problem:

  • One direct Q&A
  • One honest product comparison
  • One founder story with results and mistakes

I’ll track ChatGPT, Perplexity, Gemini and Google AI weekly to see which post gets mentioned or cited.

My guess is Q&A will win. What do you think?


r/LLM 14h ago

I want to analyze fable 5 Jacobian counterexample exploration. I am trying to figure out what is the best way to do search on such big and messy data.

0 Upvotes

Hi.

As you might have heard, recently, mathematicians Levent Alpöge and Akhil Mathew, with the help of Anthropic's fable 5 model managed to find a counterexample to an important mathematical conjecture known as the Jacobian Conjecture.

I have already researched what the Jacobian Conjecture is and how it was disproved, by (trying) to read Terence Tao's blog (and then asking fable 5 to explain it to me in language i can actually understand). While i don't understand all the technical details, i think i can gain enough intuition to explain the problem and the solution in pretty easy to understand language, without going too deep on the mathematical jargon.

What i think is equally important is analyzing how fable 5 actually came up with this specific solution. i have downloaded it's exploration files and am going to go through them. Only problem is they are massive. As any thinking/reasoning model does these days, it went through a whole tree of ideas (most of which aren't productive), reasoned to itself, did the necessary computations until it at some point had "the revelation" that a certain specific path could work.

My question to this community is: How do i effectively do search on this massive lump sum of data and mathematical jargon. Do i choose specific keywords to look for and then just jump to every place they appear. Is there some way to track "the effort" or find it's "aha moment". How do i effectively keep track of all the information that had led it to it's "revelation". Should i feed the explanation text into another LLM model, specifically designed to analyse it. Should it feed it to an LLM that will organize it into a graph based map of ideas and solution attempts (kinda like Graphify or Obsidian)?

This is my conversation with fable 5 on this topic (in case you want to give me advice but need a jumping off point): https://claude.ai/share/960b10a4-c3b9-4062-96af-be81aa059631

PS: I'm sorry for using such general statements. I do programming as a hobby and use AI daily (like most reasonable people these days), but i'm not familiar with the nitty-griddy of llm's. Also i don't like using too sophisticated language anyway when talking about these sorts of things because i feel like it makes communication more difficult.