Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

override.js 892 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  1. const overrideScoring = (namedScores, context) => {
  2. console.log('Override scoring function (JavaScript):', namedScores);
  3. const accuracyScore = namedScores.accuracy || 0;
  4. const fluencyScore = namedScores.fluency || 0;
  5. const grammarScore = namedScores.grammar || 0;
  6. const bananaScore = namedScores.banana || 0;
  7. const minScore = Math.min(accuracyScore, fluencyScore, grammarScore, bananaScore);
  8. const threshold = context?.threshold ?? 0.7;
  9. return {
  10. pass: minScore >= threshold,
  11. score: minScore,
  12. reason:
  13. `minimum score: ${minScore.toFixed(2)} (threshold: ${threshold})\n` +
  14. `Individual scores:\n` +
  15. `- contains banana: ${bananaScore.toFixed(2)}\n` +
  16. `- accuracy: ${accuracyScore.toFixed(2)}\n` +
  17. `- fluency: ${fluencyScore.toFixed(2)}\n` +
  18. `- grammar: ${grammarScore.toFixed(2)}`,
  19. };
  20. };
  21. module.exports = {
  22. overrideScoring,
  23. };
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...