|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- # BaseSamplingPipeline
-
- Namespace: LLama.Sampling
-
- Base class for implementing custom sampling pipelines. This provides a helpful framework for implementing `ISamplingPipeline`.
-
- ```csharp
- public abstract class BaseSamplingPipeline : ISamplingPipeline, System.IDisposable
- ```
-
- Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md)<br>
- Implements [ISamplingPipeline](./llama.sampling.isamplingpipeline.md), [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-
- ## Properties
-
- ### **Grammar**
-
- Grammar to constrain valid tokens
-
- ```csharp
- public SafeLLamaGrammarHandle Grammar { get; set; }
- ```
-
- #### Property Value
-
- [SafeLLamaGrammarHandle](./llama.native.safellamagrammarhandle.md)<br>
-
- ## Methods
-
- ### **Sample(SafeLLamaContextHandle, Span<Single>, ReadOnlySpan<LLamaToken>)**
-
- ```csharp
- public LLamaToken Sample(SafeLLamaContextHandle ctx, Span<float> logits, ReadOnlySpan<LLamaToken> lastTokens)
- ```
-
- #### Parameters
-
- `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)<br>
-
- `logits` [Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)<br>
-
- `lastTokens` [ReadOnlySpan<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)<br>
-
- #### Returns
-
- [LLamaToken](./llama.native.llamatoken.md)<br>
-
- ### **Accept(SafeLLamaContextHandle, LLamaToken)**
-
- ```csharp
- public void Accept(SafeLLamaContextHandle ctx, LLamaToken token)
- ```
-
- #### Parameters
-
- `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)<br>
-
- `token` [LLamaToken](./llama.native.llamatoken.md)<br>
-
- ### **ProcessLogits(SafeLLamaContextHandle, Span<Single>, ReadOnlySpan<LLamaToken>)**
-
- Process the raw logit values
-
- ```csharp
- protected abstract void ProcessLogits(SafeLLamaContextHandle ctx, Span<float> logits, ReadOnlySpan<LLamaToken> lastTokens)
- ```
-
- #### Parameters
-
- `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)<br>
- The context being sampled from
-
- `logits` [Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)<br>
- The logits produced by the model
-
- `lastTokens` [ReadOnlySpan<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)<br>
- A list of tokens recently returned by the model
-
- ### **ProcessTokenDataArray(SafeLLamaContextHandle, LLamaTokenDataArray, ReadOnlySpan<LLamaToken>)**
-
- Process the LLamaTokenDataArray and select a single token
-
- ```csharp
- protected abstract LLamaToken ProcessTokenDataArray(SafeLLamaContextHandle ctx, LLamaTokenDataArray candidates, ReadOnlySpan<LLamaToken> lastTokens)
- ```
-
- #### Parameters
-
- `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)<br>
- The context being sampled from
-
- `candidates` [LLamaTokenDataArray](./llama.native.llamatokendataarray.md)<br>
- The LLamaTokenDataArray data produced by the model
-
- `lastTokens` [ReadOnlySpan<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)<br>
- A list of tokens recently returned by the model
-
- #### Returns
-
- [LLamaToken](./llama.native.llamatoken.md)<br>
-
- ### **Reset()**
-
- ```csharp
- public void Reset()
- ```
-
- ### **Clone()**
-
- ```csharp
- public abstract ISamplingPipeline Clone()
- ```
-
- #### Returns
-
- [ISamplingPipeline](./llama.sampling.isamplingpipeline.md)<br>
-
- ### **Dispose()**
-
- ```csharp
- public void Dispose()
- ```
|