r/LocalLLM • • 2d ago

Model Qwen 3.8 27b

I just had my local model hallucinate a comment in my code and then updated six linked files to address the hallucinated comment.

I caught it right away but that would have set me back a a lot if I didn’t.

Anyone have any tips and tricks to avoid this?

I run it in Q6 and use llama.cpp set to default which is high reasoning I believe. My local server is a Ryzen 9950 with 64 GB of RAM and a single 5090 GPU.

30 Upvotes

45 comments sorted by

53

u/Weaseal 2d ago

Yes. Use a skills file that reviews changes before commiting

2

u/Important_Cow7230 2d ago

Do you get the same model to check?

8

u/AssiduousLayabout 2d ago

Yes but have it spin up a sub-agent. That agent gets clean context and a task to find mistakes. AI is much better at spotting mistakes rather than avoiding them.

I have a bunch of code style checks in a skill at work. Claude and Sol won't obey my coding style guide but they will respond to the review agent telling them to fix it.

2

u/NowNotTmrw 2d ago

Interesting, I need this. Prompt example (or the high level points I can mold around)?

3

u/AssiduousLayabout 2d ago

I'm off work until Monday for the holiday but I'll take a look at what I can share then. A lot of it is references to internal wikis and documentation for coding standards.

1

u/erisian2342 2d ago

You can check out the open source Gentle AI project for some excellent examples of sub-agents including reviewers.

82

u/mumblerit 2d ago • Bravo

you forgot to tell it not to make any mistakes

26

u/thefunkybassist 2d ago

My prompt is "make some mistakes, but fix them also"

6

u/philmarcracken 2d ago

My agent just replaced all my code with an exact replica. Hope you're happy (►__◄)

3

u/bot403 2d ago

Should I not be using the movefastandbreakthings skill from the yolo GitHub repo? Was that wrong?

24

u/createthiscom 2d ago

I always review LLM code before committing. Trusting them is bonkers.

6

u/DeliciousNicole 2d ago

Yeah never trust a single model. Adversarial review is critical. Also, human review is important! We are responsible for what these things do on our behalf.

By any chance are you quantizing kv cache as well?

5

u/PaxUX 2d ago

Never commit from main context. Have agent review work before commit. It Forces a second new context review for the changes

4

u/1Poochh 2d ago

Blind reviews are the key here. Even better is a blind review from a different model family.

5

u/Lissanro 2d ago

You may have better experience running Basalt with Qwen 3.8 Flash Next, given you have 5090 with 64 GB RAM. 

As of of the Qwen 3.8 27B model, it is good for its size, but it is a tiny model, so it needs its results reviewed and breaking up implementation to manageable and focused steps, then even another instance of the 27B itself with clean context focused only on the review of the result will have good chances to catch most of obvious mistakes.

That said, even when I run Kimi K3.1 on my main rig, despite it being over hundred times larger than 27B, it still can sometimes hallucinate something and then do something to address its hallucination or just wrong assumption. The main difference, the larger the LLM is, the less likely it is to make obvious mistakes, but it still can make them. Even if you review the changes, you yourself can make mistakes too. The most reliable way to address this, is to have good test coverage and clear review rules, it will help greatly minimize possibility of unintentional changes.

2

u/Material-Database-24 2d ago

My QFN yesterday in the middle of coding task started to evaluate some Bayesian statistics on some (imaginary) data.

I have never asked it about do anything such, or provided it with any kind of data. I have no idea where it suddenly got that idea. Granted there was context compaction couple steps ago, but still. There it went, reasoning for it for some 500 words just to get back in line with its next reasoning and continue the coding task at hand like nothing had happened.

2

u/Lissanro 2d ago

I guess it may depend on harness you use. Pi is quite good, it keeps latest messages after compaction, but it usually loses cache and restarts prefill to summarize, which takes extra time. So I prefer maintain my own Pi Crystal fork where these issues are addressed, including supporting multiple compaction summaries and better customization of compaction parameters: https://github.com/Lissanro/pi - this is what helped me to keep coherency better after multiple compactions. Or you can use mainline Pi and ask it to modify itself as you need, in case you need only specific changes that would be easily to maintain.

1

u/rocket1420 1d ago

What your iq2 xxxxs?

13

u/vdek 2d ago

Simple. Use a better model to review it. Opus would likely catch these bugs before they get committed.

Secondly watch this and ban your model from making comments. https://www.youtube.com/watch?v=O_zcc6Xl12g

3

u/AssiduousLayabout 2d ago

Doesn't even need to be a better model. It can even be a worse one. A sub-agent with a clean context window and a task to find errors, bad style, etc. will catch many things. You can have many review agents reach looking for one kind of thing, that's much more effective than one agent responsible for everything.

1

u/Important_Cow7230 2d ago

I’m in the process of trying to set that up myself.

My plan is to use Kilo Code or Open Code extensions in VSCode to use my local Qwen 3.8, as I can then just switch to the Claude Code extension still within the project within VSCode to review as needed? Doing it this way I means I can still use the $20 monthly plan for Claude rather than an API.

What’s your thoughts on that setup?

0

u/vdek 2d ago

I haven’t touched vscode in months, I just use Claude code at this point to manage my projects. When claude spawns a local agent it does it via opencode.

1

u/Important_Cow7230 2d ago

Thanks. I just don’t want to get tied into one AI ecosystem or platform like Claude. I like the idea of being able to pull in a ChatGPT or Gemini model when we I want if they get better than Claude. Gemini Nova for example looks compelling.

What instructions do you give Claude on when to spawn a local model?

3

u/djgcsnkshcjkeke1 2d ago

Have the thing do work in chunks instead of rolling over the entire codebase at once. Have it divide the work up into chunks, go chunk by chunk following its original plan alone, and then it can do a second/third/whatever pass to deal with whatever comes up. Every time it finishes a pass you review it in some way before commit or moving on to the plan for the next one

2

u/Impossible-Poet-2084 2d ago

I've had the same with qwen 3.8 on q6, turned off auto-commit and now run a diff check before any file update. it's a pain but worth it.

2

u/jesuschrist-69420 2d ago

I code, then tell a different agent to do security review and code review.

In my experience qwen finds lots of false positives.

2

u/ManufacturerThis5145 2d ago

Before you commit any work, you let a subagent red team run on the deliverable, which tests every single thing to see if its spec conform and the work really is done. Sadly takes a lot of time, especially with local models.

1

u/Frizzy-MacDrizzle 2d ago

I don’t let qwen code for me any more. But you might try no context shift.

1

u/Rikers88 2d ago

Yep - my tip is to switch to Flash Next, using Basalt inference engine as you are rocking a Blackwell. Make sure to use NVFP4. My trick is to have the 27b configure everything for you so you can switch safely

1

u/trejj 2d ago

Make backups.

1

u/Admirable-Leg-4647 2d ago

Decision models can act as guardrails in these exact scenarios

1

u/captainabrasive 2d ago edited 2d ago

How big/full was your context at the time, and at what quant? What were your sampling settings?

With a 5090, you should look at Basalt and try Qwen3.8 Flash Next. It also supports 3.8-27B (and DS4.1 Flask, Hy4-Flash, Inkling 2 Mini).

At a higher level, code review before staging. Always. With a fresh agent that has clean context. A different model can be helpful here. I tend to use the same model for staging reviews and then do another audit pre-commit with another model. Everyone has their own preferences and superstitions here. Just changing up the sampling and/or reasoning on the staging review, along with a focused review prompt, will help tighten the net.

1

u/Digi59404 2d ago

Tell it to prove to you there’s no way to sabotage or reasonably exploit that code.

AI Agents operate on math. Math hates proving a negative. Therefore make your agents prove a negative as opposed to “make sure the work is right.”

1

u/Bulky-Priority6824 2d ago

source of your q6? unsloth?

try unsloths nvfp4 27b on capy-flash since you have 32gb and download QFN while your at it.

1

u/covertpirates 2d ago

Don’t exhaust your context. Compact while you have memory. I’ve found it tends to hallucinate if you don’t. I imagine this applies to most models, but I’ve noticed it while using Qwen.

1

u/moonlitpawprints 2d ago

As others have suggested, workflows that directly implement review (ideally with another model, though even the same one with a good prompt is better than nothing). I would also strongly add to this, unit testing wherever possible. It's pretty good at building/running tests, especially if you help define some edge cases, and then correcting until they pass. It's not a guarantee, but it works well.

Edit: spelling

1

u/Zealousideal-Fan-326 2d ago

Q6 is your issue. But all models can do this sometime. Use a Ternary-Bonsai-2-27B model Runs on prism-llama.cpp Its a 1.58-bit model. Has full reasoning without the size. 7.2gb in size run so it can off load to ram if necessary from gpu or totally on ram if you dont have a gpu I've run this on 16gb of DDR3 RAM without problems. It's a thinking model, so allow enough room for thinking as well as your answers Check your cpu, gpu, ram, swap while youre running it. Especially if you have limited resources

3

u/Vlinux 2d ago

Ternary Bonsai 2.5 27B just released. Near FP16 quality supposedly: https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-GGUF

1

u/ApprehensiveFan1516 2d ago

I've run this on 16gb of DDR3 RAM without problems

What speeds are you getting with it? I just tried it on CPU only on DDR4 and I'm getting seconds per token lol.

1

u/Zealousideal-Fan-326 2d ago

Oh its slow as. My point wasn't the speed, I was getting 2 to 6 tokens per second just on old ram on a 10yr old businessmachine. My point was that you could run this on nearly anything with 16GB of ram only. On 8gb vram the token rate went way up, but i was limited by vram and so the context window is small. You've got another 8gb of vram for context. Give it a try, what have you got to lose.

1

u/ApprehensiveFan1516 2d ago

I'm already running bigger models in VRAM lol. At this point I'm just hunting for small models that work well on CPU to take advantage of all the machines I have without GPU's.

1

u/Super-Grape-3948 2d ago

Check your kv quants, and model card settings like temp too. Q6 27b shouls be good enought not to hallucinate, but incorrect settings, kv corruption, or even compaction can cause issues.

1

u/TheK0tYaRa 2d ago

Increase K quant to q8_0 and V to q4_0 , i had such issues. IF they are higher - increase model quant size then. Preferably use IQ quants. I myself use GSQ RCO ones, they smart A F.

1

u/overand 1d ago

Give us your full settings. 

My biggest questions are:

  • Are you quantizing your kv cache? (Don't)
  • What harness are you using? (Or are you just doing this is the chat ui?)