Hacker News new | ask | show | jobs
by danenania 844 days ago
I'm working on an LLM project in Go and the term "context" is overloaded to the hilt--I use it to refer to the LLM context as well as Go's `context.Context` which I'm using all over the place. It's made worse since the most natural plural of context is... context. My solution is to use `ctx` for Go context, `contexts` for arrays of LLM context structs, and `contextPart` for individual context structs.

"model" is another one like that since I'm using it to refer to both data models and ML models. And "prompt" since it can be an LLM prompt or a terminal prompt for the user (this is a CLI tool).

Differentiating all these overlapping terms in ways that aren't super confusing is definitely a challenge.

1 comments

Context is actually one of my least favorite parts of go. I wish they at least reimplemented it with generics so it’s not just a unlabeled box of maybe some stuff that can also cancel things
Yeah it's definitely a bit of a junk drawer. I'm using it for timeouts, cancelation, and cancelation trees and it's not so bad, but I know it can also be used to pass data around which doesn't strike me as a great idea.