Skip to content

Commit

Permalink
update leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed May 11, 2024
1 parent c563e08 commit d172d1a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 41 deletions.
41 changes: 23 additions & 18 deletions MyApp.Tests/Top1KQuestionTasks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using MyApp.ServiceModel;
using MyApp.Data;
using MyApp.Migrations;
using MyApp.ServiceModel;
using NUnit.Framework;
using ServiceStack;
using ServiceStack.Text;
Expand All @@ -8,19 +10,6 @@ namespace MyApp.Tests;
[Explicit]
public class Top1KQuestionTasks
{
private List<string> top10Models =
[
"claude3-opus",
"claude3-sonnet",
"claude3-haiku",
"mixtral",
"gemini-pro",
"mistral",
"gemma",
"deepseek-coder",
"gemma-2b",
];

[Test]
public async Task Find_Missing_Top1K_Questions_For_Model()
{
Expand All @@ -39,8 +28,6 @@ public async Task Find_Missing_Top1K_Questions_For_Model()
[Test]
public async Task Create_missing_Top1K_Answers_for_Models()
{
// var model = "mixtral";

var client = TestUtils.CreateProdClient();
await client.ApiAsync(new Authenticate
{
Expand All @@ -49,7 +36,9 @@ await client.ApiAsync(new Authenticate
Password = Environment.GetEnvironmentVariable("AUTH_SECRET")
});

foreach (var model in top10Models)
var allModels = AppConfig.ModelsForQuestions.Select(x => x.Model).ToList();
allModels.Remove("deepseek-coder-33b");
foreach (var model in allModels)
{
await CreateMissing1KModelsForModelAsync(client, model);
}
Expand Down Expand Up @@ -93,6 +82,22 @@ private static async Task CreateMissing1KModelsForModelAsync(JsonApiClient clien
apiCreate.Response!.Results.PrintDump();
}

[Test]
public async Task Recreate_answers_for_Top1K_questions_for_phi()
{
var client = await TestUtils.CreateAuthenticatedProdClientAsync();
var apiCreate = await client.ApiAsync(new CreateAnswersForModel
{
Model = "phi",
PostIds = Migration1005.Top1KIds,
});

apiCreate.Error.PrintDump();
apiCreate.ThrowIfError();
apiCreate.Response!.Errors.PrintDump();
apiCreate.Response!.Results.PrintDump();;
}

[Test]
public async Task Find_answers_that_have_not_been_individually_graded()
{
Expand All @@ -107,7 +112,7 @@ public async Task Find_answers_that_have_not_been_individually_graded()

if (api.Response!.Results.Count == 0)
{
$"No more ungraded answers".Print();
"No more ungraded answers".Print();
return;
}

Expand Down
35 changes: 20 additions & 15 deletions MyApp/Components/Pages/Leaderboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

@if (TotalVotes.Count > 0 && WinRates.Count > 0)
{
<h3 class="text-center py-12 text-4xl font-bold tracking-tight text-gray-900 dark:text-gray-100 sm:text-5xl">Top 1000 Leaderboard</h3>
<h3 class="text-center py-12 text-4xl font-bold tracking-tight text-gray-900 dark:text-gray-100 sm:text-5xl">Top 1K Leaderboard</h3>

<div class="mt-8 mx-auto">
<div>
<div style="min-height:528px">
<div data-component="pages/Leaderboard/TotalVotes1K.mjs" data-props=@ToProps(Top1kVotes)></div>
</div>
<p class="py-8 text-center">
Based on total number of total votes received for answers of the Top 1000 questions <br>
Based on total number of total votes received for answers of the Top 1K most voted questions <br>
</p>
<div class="flex justify-center">
<LeaderboardStats Title="Total Votes" Results=@Top1kVotes />
Expand All @@ -31,27 +31,32 @@

<h3 class="text-center py-12 text-4xl font-bold tracking-tight text-gray-900 dark:text-gray-100 sm:text-5xl">All Questions Leaderboard</h3>

<h3 class="mt-24 mb-8 text-2xl font-semibold">Total Votes for All Questions</h3>
<div data-component="pages/Leaderboard/TotalVotes.mjs" data-props=@ToProps(TotalVotes)></div>

<h3 class="mt-24 mb-8 text-2xl font-semibold">Win Rates for participating Questions</h3>
<div style="min-height:528px">
<div data-component="pages/Leaderboard/WinRates.mjs" data-props=@ToProps(WinRates)></div>
</div>
<p class="py-4 text-center">
Based on number of total votes received by each model by a <a class="text-indigo-600 dark:text-indigo-300" href="/posts/leaderboard-intro">ranking model</a> measuring how well they answer the question asked
Calculated win rate of each model based on their participation in questions where they received votes.
</p>

<div class="mt-8 flex justify-between gap-x-8 max-w-screen-md mx-auto">
<LeaderboardStats Title="Total Votes" Results=@TotalVotes />
<LeaderboardStats Title="Win Rates" Results=@WinRates />
<LeaderboardStats Title="Total Votes" Results=@TotalVotes />
</div>

<p class="py-4 text-center">
Win Rates table includes questions participated (in brackets) to calculate its win rate
</p>

<h3 class="mt-24 mb-8 text-2xl font-semibold">Win Rates for participating Questions</h3>
<div data-component="pages/Leaderboard/WinRates.mjs" data-props=@ToProps(WinRates)></div>

<h3 class="mt-24 mb-8 text-2xl font-semibold">Total Votes for All Questions</h3>
<div style="min-height:528px">
<div data-component="pages/Leaderboard/TotalVotes.mjs" data-props=@ToProps(TotalVotes)></div>
</div>
<p class="py-4 text-center">
Calculated win rate of each model based on their participation in questions where they received votes.
Based on number of total votes received by each model by a <a class="text-indigo-600 dark:text-indigo-300" href="/posts/leaderboard-intro">ranking model</a> measuring how well they answer the question asked
</p>

<div class="mt-24 text-center text-sm">
<a class="text-indigo-600 dark:text-indigo-300" href="/posts/leaderboard-intro">how results are calculated</a>
<div class="text-gray-500">* results updated daily</div>
Expand Down Expand Up @@ -102,7 +107,7 @@
AvatarUrl = AppConfig.GetUserName(x.Id).GetAvatarUrl(),
Stat = $"{x.StartingUpVotes.ToHumanReadable()}",
Value = x.StartingUpVotes,
}).Take(10).ToList();
}).Take(18).ToList();

WinRates = allData.ModelWinRate.OrderByDescending(x => x.WinRate).Select((x, index) =>
new LeaderboardStat
Expand All @@ -112,7 +117,7 @@
AvatarUrl = AppConfig.GetUserName(x.Id).GetAvatarUrl(),
Stat = $"{Math.Round(x.WinRate, 2)}% ({x.NumberOfQuestions.ToHumanReadable()})",
Value = Math.Round(x.WinRate, 2),
}).Take(10).ToList();
}).Take(18).ToList();

Top1kVotes = top1kData.MostLikedModelsByLlm.OrderByDescending(x => x.StartingUpVotes).Select((x, index) =>
new LeaderboardStat
Expand All @@ -122,6 +127,6 @@
AvatarUrl = AppConfig.GetUserName(x.Id).GetAvatarUrl(),
Stat = $"{x.StartingUpVotes.ToHumanReadable()}",
Value = x.StartingUpVotes,
}).Take(10).ToList();
}).Take(18).ToList();
}
}
4 changes: 2 additions & 2 deletions MyApp/Migrations/Migration1005.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class QuestionGroup
public override void Up()
{
Db.CreateTable<QuestionGroup>();
var top1kRows = Top1000Ids.Map(x => new QuestionGroup { Id = x, Group = PostGroup.Top1K });
var top1kRows = Top1KIds.Map(x => new QuestionGroup { Id = x, Group = PostGroup.Top1K });
Db.BulkInsert(top1kRows);
}

Expand All @@ -27,7 +27,7 @@ public override void Down()
Db.DropTable<QuestionGroup>();
}

private List<int> Top1000Ids =
public static List<int> Top1KIds =
[
927358,
292357,
Expand Down
4 changes: 2 additions & 2 deletions MyApp/wwwroot/pages/Leaderboard/TotalVotes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
export default {
components: { ChartJs },
template: `
<ChartJs :data="data" :plugins="{ legend: { position: 'left' } }" />
<ChartJs :data="data" :plugins="{ legend: { position: 'left' } }" style="width:1024px" />
`,
props:['results'],
setup(props) {
let results = props.results
results.sort((a,b) => b.value - a.value)
results = results.slice(0,10)
results = results.slice(0,20)

const datasets = results.map((x,i) => ({
label: x.displayName,
Expand Down
4 changes: 2 additions & 2 deletions MyApp/wwwroot/pages/Leaderboard/TotalVotes1K.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
setup(props) {
let results = props.results
results.sort((a,b) => b.value - a.value)
results = results.slice(0,10)
results = results.slice(0,20)

const datasets = results.map((x,i) => ({
label: x.displayName,
Expand All @@ -32,7 +32,7 @@ export default {
},
title: {
display: true,
text: 'Total Votes for Top 1000 Questions',
text: 'Total Votes for Top 1K Most Voted Questions',
font: {
size: 20,
}
Expand Down
4 changes: 2 additions & 2 deletions MyApp/wwwroot/pages/Leaderboard/WinRates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
export default {
components: { ChartJs },
template: `
<ChartJs :data="data" :plugins="{ legend: { position: 'left' } }" />
<ChartJs :data="data" :plugins="{ legend: { position: 'left' } }" style="width:1024px" />
`,
props:['results'],
setup(props) {
let results = props.results
results.sort((a,b) => b.value - a.value)
results = results.slice(0,10)
results = results.slice(0,20)

const datasets = results.map((x,i) => ({
label: x.displayName,
Expand Down

0 comments on commit d172d1a

Please sign in to comment.