MCPcopy Index your code
hub / github.com/LargeWorldModel/LWM / encode_and_trim

Method encode_and_trim

scripts/eval_needle_multi.py:137–141  ·  view source on GitHub ↗
(self, context, context_length)

Source from the content-addressed store, hash-verified

135 return contexts
136
137 def encode_and_trim(self, context, context_length):
138 tokens = self.enc.encode(context)
139 if len(tokens) > context_length:
140 context = self.enc.decode(tokens[:context_length])
141 return context
142
143 def create_contexts(self, needles_info, random_cities_retrieve, context, context_length, seed):
144 assert all([random_city in needles_info for random_city in random_cities_retrieve])

Callers

nothing calls this directly

Calls 2

encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected