You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: LLama/Native/NativeApi.Sampling.cs
+29-1Lines changed: 29 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
-
usingSystem.Runtime.InteropServices;
1
+
usingSystem;
2
+
usingSystem.Runtime.InteropServices;
2
3
3
4
namespaceLLama.Native
4
5
{
@@ -23,6 +24,33 @@ public static extern unsafe void llama_sample_repetition_penalties(SafeLLamaCont
23
24
floatpenalty_freq,
24
25
floatpenalty_present);
25
26
27
+
/// <summary>
28
+
/// Apply classifier-free guidance to the logits as described in academic paper "Stay on topic with Classifier-Free Guidance" https://arxiv.org/abs/2306.17806
29
+
/// </summary>
30
+
/// <param name="ctx"></param>
31
+
/// <param name="logits">Logits extracted from the original generation context.</param>
32
+
/// <param name="logits_guidance">Logits extracted from a separate context from the same model.
33
+
/// Other than a negative prompt at the beginning, it should have all generated and user input tokens copied from the main context.</param>
34
+
/// <param name="scale">Guidance strength. 1.0f means no guidance. Higher values mean stronger guidance.</param>
/// Apply classifier-free guidance to the logits as described in academic paper "Stay on topic with Classifier-Free Guidance" https://arxiv.org/abs/2306.17806
0 commit comments