MCPcopy
hub / github.com/oobabooga/textgen / generate_reply_HF

Function generate_reply_HF

modules/text_generation.py:312–503  ·  view source on GitHub ↗
(question, original_question, state, stopping_strings=None, is_chat=False)

Source from the content-addressed store, hash-verified

310
311
312def generate_reply_HF(question, original_question, state, stopping_strings=None, is_chat=False):
313 import torch
314 import transformers
315 from transformers import LogitsProcessorList
316
317 from modules.grammar.grammar_utils import initialize_grammar
318 from modules.grammar.logits_process import (
319 GrammarConstrainedLogitsProcessor
320 )
321 from modules.torch_utils import clear_torch_cache, get_device
322 from modules.transformers_loader import (
323 Stream,
324 _StopEverythingStoppingCriteria
325 )
326
327 if shared.args.loader == 'Transformers':
328 clear_torch_cache()
329
330 seed = set_manual_seed(state['seed'])
331
332 generate_params = {}
333 for k in [
334 'temperature',
335 'dynatemp_low',
336 'dynatemp_high',
337 'dynatemp_exponent',
338 'smoothing_factor',
339 'smoothing_curve',
340 'min_p',
341 'top_p',
342 'top_k',
343 'typical_p',
344 'xtc_threshold',
345 'xtc_probability',
346 'tfs',
347 'top_a',
348 'top_n_sigma',
349 'adaptive_target',
350 'adaptive_decay',
351 'dry_multiplier',
352 'dry_allowed_length',
353 'dry_base',
354 'repetition_penalty',
355 'frequency_penalty',
356 'presence_penalty',
357 'encoder_repetition_penalty',
358 'no_repeat_ngram_size',
359 'repetition_penalty_range',
360 'penalty_alpha',
361 'guidance_scale',
362 'mirostat_mode',
363 'mirostat_tau',
364 'mirostat_eta',
365 'max_new_tokens',
366 'do_sample',
367 'dynamic_temperature',
368 'temperature_last',
369 'dry_sequence_breakers',

Callers

nothing calls this directly

Calls 15

clear_torch_cacheFunction · 0.90
apply_extensionsFunction · 0.90
initialize_grammarFunction · 0.90
get_deviceFunction · 0.90
set_manual_seedFunction · 0.85
encodeFunction · 0.85
get_max_prompt_lengthFunction · 0.85
print_promptFunction · 0.85
decodeFunction · 0.85

Tested by

no test coverage detected