[MN-05] Tokenizer Initialization is Expensive #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Full Detail:
KnowledgeService.cscreates a newTiktokenTokenizerinstance in its constructor (line 44). SinceKnowledgeServiceis registered as Scoped, a new tokenizer is initialized for every request/session, which is CPU and memory intensive.Action:
_tokenizerto be astaticfield inKnowledgeService.Tokenizeras aSingletoninInfrastructure/DependencyInjection.csand inject it.