You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
- using System.Runtime.InteropServices;
-
- namespace LLama.Native;
-
- /// <summary>
- /// Passed to beam_search_callback function.
- /// Whenever 0 < common_prefix_length, this number of tokens should be copied from any of the beams
- /// (e.g. beams[0]) as they will be removed (shifted) from all beams in all subsequent callbacks.
- /// </summary>
- [StructLayout(LayoutKind.Sequential)]
- public readonly struct LLamaBeamsState
- {
- /// <summary>
- /// The state of each individual beam
- /// </summary>
- private readonly unsafe LLamaBeamView* beam_views;
-
- /// <summary>
- /// Number of elements in beam_views
- /// </summary>
- private readonly nint n_beams;
-
- /// <summary>
- /// Current max length of prefix tokens shared by all beams.
- /// </summary>
- public readonly ulong CommonPrefixLength;
-
- /// <summary>
- /// True iff this is the last callback invocation.
- /// </summary>
- public readonly bool LastCall;
-
- /// <summary>
- /// The current state of each beam
- /// </summary>
- public Span<LLamaBeamView> Beams
- {
- get
- {
- unsafe
- {
- if (n_beams > int.MaxValue)
- throw new InvalidOperationException("More than 2147483647 beams is not supported");
- return new Span<LLamaBeamView>(beam_views, (int)n_beams);
- }
- }
- }
- }
|