fix for typical sampler
This commit is contained in:
parent
0c3a265187
commit
d7fed4732f
2 changed files with 9 additions and 2 deletions
|
@ -1234,6 +1234,7 @@ struct llama_model_loader {
|
||||||
|
|
||||||
// determine file type based on the number of tensors for each quantization and print meta data
|
// determine file type based on the number of tensors for each quantization and print meta data
|
||||||
// TODO: make optional
|
// TODO: make optional
|
||||||
|
if(false) //disable this log for now
|
||||||
{
|
{
|
||||||
std::map<enum ggml_type, uint32_t> n_type;
|
std::map<enum ggml_type, uint32_t> n_type;
|
||||||
|
|
||||||
|
@ -3974,8 +3975,11 @@ void llama_sample_typical(struct llama_context * ctx, llama_token_data_array * c
|
||||||
|
|
||||||
float entropy = 0.0f;
|
float entropy = 0.0f;
|
||||||
for (size_t i = 0; i < candidates->size; ++i) {
|
for (size_t i = 0; i < candidates->size; ++i) {
|
||||||
|
if(candidates->data[i].p>0)
|
||||||
|
{
|
||||||
entropy += -candidates->data[i].p * logf(candidates->data[i].p);
|
entropy += -candidates->data[i].p * logf(candidates->data[i].p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Compute the absolute difference between negative log probability and entropy for each candidate
|
// Compute the absolute difference between negative log probability and entropy for each candidate
|
||||||
std::vector<float> shifted_scores;
|
std::vector<float> shifted_scores;
|
||||||
|
|
|
@ -2663,8 +2663,11 @@ void llama_v3_sample_typical(struct llama_v3_context * ctx, llama_v3_token_data_
|
||||||
|
|
||||||
float entropy = 0.0f;
|
float entropy = 0.0f;
|
||||||
for (size_t i = 0; i < candidates->size; ++i) {
|
for (size_t i = 0; i < candidates->size; ++i) {
|
||||||
|
if(candidates->data[i].p>0)
|
||||||
|
{
|
||||||
entropy += -candidates->data[i].p * logf(candidates->data[i].p);
|
entropy += -candidates->data[i].p * logf(candidates->data[i].p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Compute the absolute difference between negative log probability and entropy for each candidate
|
// Compute the absolute difference between negative log probability and entropy for each candidate
|
||||||
std::vector<float> shifted_scores;
|
std::vector<float> shifted_scores;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue