Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(verbosity): better handling for verbosity #109

Merged
merged 27 commits into from
Sep 12, 2024

Conversation

cohow
Copy link
Contributor

@cohow cohow commented Aug 31, 2024

Resolves #94

Reward is now calculated based on (count^expo) * multiplier * score * multiplierFactor.multiplier

for example, im going to use issue #95
reward calculation was the following

image

the new verbosity algorithm would take ((65^0.85) * 0.1 * 1 * 3) + ((16^0.85) * 0.1 * 0 * 3) which would equal to 10.42 instead of the old 19.5
image

Please check and let me know if there's any issues, also I not sure if it's an issue but I had to create a different _calculateFormattingTotal for calculations due to cognitive complexity related issues from lint

gentlementlegen and others added 16 commits June 11, 2024 11:50
feat: split reward between multiple assignees
…please--branches--main

chore(main): release 1.3.0
feat: using latest ChatGpt version and fixed truncated results
…please--branches--main

chore(main): release 1.3.1
…-please--branches--main

chore(main): release 1.4.0
@gentlementlegen
Copy link
Member

@cohow Thank you for the PR. I am fine with the changes, please fix the Jest tests that all broke due to the results changing with the formula.

@cohow
Copy link
Contributor Author

cohow commented Sep 1, 2024

@cohow Thank you for the PR. I am fine with the changes, please fix the Jest tests that all broke due to the results changing with the formula.

I was looking at the tests and it seems like the problem is coming from the results not equaling the mock results and was wondering if there was a way to generate a new mock results file without having to edit all the rewards separately, if not then I'll just manage to figure something out.

image

@gentlementlegen
Copy link
Member

@cohow When I want to update them I copy paste the diff of the proper result so I don't have to manually fix all the numbers.

However according to your screenshot there are lots of decimals to the results. I don't know if that's what we want.

@cohow
Copy link
Contributor Author

cohow commented Sep 2, 2024

I believe these changes should fix all the issues with the mock results being incorrect.

I've also changed the calculation to cut off at 2 decimal places because exponents tend to produce a lot of decimals. If you want I can also change it to round up or down, but that would require all the tests to be changed again.

let me know if anything goes wrong or any expected results appear, or you require any changes, I'll try to get a fix out ASAP.

Comment on lines 85 to 97
for (const symbol of Object.keys(curr.symbols)) {
const count = new Decimal(curr.symbols[symbol].count);
const symbolMultiplier = new Decimal(curr.symbols[symbol].multiplier);
const formattingElementScore = new Decimal(curr.score);
const exponent = this._wordCountExponent;

sum = sum.add(
count
.pow(exponent) // (count^exponent)
.mul(symbolMultiplier) // symbol multiplier
.mul(formattingElementScore) // comment type multiplier
.mul(multiplierFactor.multiplier) // formatting element score
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

word count exponent is being applied to all symbols, either we leave it like that but we should rename it to symbol exponent, or we can limit it to only words @0x4007

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure but I feel like word count specifically makes the most sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that config doesn't define word multiplier anymore, instead symbol regexes are used and technically two regexes which are a little bit different can both represent words so it's hard to apply the exponent only to the word count

Copy link
Member

@0x4007 0x4007 Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a proposal for "segments" which would serve as aliases for word regex, sentence regex, paragraph regex, entire comment regex. Perhaps we can rely on that as the main "word counter."

Ultimately I think we should strive to make the config user friendly/idiot proof but I think its impossible to cover every situation for abuse proactively. I think we should define "best practices" and hope that partners don't shoot themselves in the foot with conflicting/bad configs.

Copy link
Contributor

@whilefoo whilefoo Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with having segments as aliases, we can keep regexes but I don't think many partners will bother to use that

@0x4007
Copy link
Member

0x4007 commented Sep 3, 2024

I've also changed the calculation to cut off at 2 decimal places because exponents tend to produce a lot of decimals. If you want I can also change it to round up or down, but that would require all the tests to be changed again.

Use a numbers library like bignumber to handle this.

@cohow
Copy link
Contributor Author

cohow commented Sep 3, 2024

I've also changed the calculation to cut off at 2 decimal places because exponents tend to produce a lot of decimals. If you want I can also change it to round up or down, but that would require all the tests to be changed again.

Use a numbers library like bignumber to handle this.

bignumber to handle the rounding or cutting off decimals? right now decimal.js is able to handle both actually so I'm not sure if another library would be needed.

@0x4007
Copy link
Member

0x4007 commented Sep 3, 2024

Sure use decimal for all calculations.

@cohow
Copy link
Contributor Author

cohow commented Sep 8, 2024

if I'm not wrong the last checks tests depend on #108 or one of the issues that were linked in it. LMK if you need anything else!

@gentlementlegen
Copy link
Member

@cohow You mean that your pull-request test fixes depend on another pull-request?

@cohow
Copy link
Contributor Author

cohow commented Sep 9, 2024

@cohow You mean that your pull-request test fixes depend on another pull-request?

The last tests failed due issues with permit generation, which is not caused by this PR and after checking other PRS I believe PR #108 fixes that issue if I'm not wrong

@gentlementlegen
Copy link
Member

After checking the logs, it seems that everything works as expected but since your changes also modified the results the permit urls got changed as well (for example check https://github.com/ubiquibot/conversation-rewards/actions/runs/10753678522/job/29832632935?pr=109#step:4:432) so you should just have to fix the result and every test should pass.

@cohow
Copy link
Contributor Author

cohow commented Sep 9, 2024

After checking the logs, it seems that everything works as expected but since your changes also modified the results the permit urls got changed as well (for example check https://github.com/ubiquibot/conversation-rewards/actions/runs/10753678522/job/29832632935?pr=109#step:4:432) so you should just have to fix the result and every test should pass.

Ok that does make sense considering mock results are pre made.. I'm not sure why but I thought permits were being generated on the spot. I'll push changes to fix those issues when when I'm back from my class.

@gentlementlegen
Copy link
Member

@cohow Seems that the tests are still failing. I would advise running them locally or on your own repo to avoid having to wait for me revalidating workflows every time.

@cohow
Copy link
Contributor Author

cohow commented Sep 11, 2024

ok I'm really shocked how many attempts this took for me to fix, but I finally fixed the tests I believe, tested locally and they passed.

@cohow
Copy link
Contributor Author

cohow commented Sep 12, 2024

Seems like the permit URLs have changed, i’ll get a fix out asap.

@cohow
Copy link
Contributor Author

cohow commented Sep 12, 2024

Quite lost on why I keep getting 2 different test results between when I run it locally and Github actions

for example https://github.com/ubiquibot/conversation-rewards/actions/runs/10832843625/job/30060543240#step:4:580 Its expecting a 1.57 but receives 1.232 and when I change them I get the exact opposite

            "relevance": 1,
-           "reward": 1.232,
+           "reward": 1.57,

@gentlementlegen
Copy link
Member

This is probably because you are using your own credentials so the status you see for the other user differs from when Ubiquibot checks the author association, changing the reward results. Also, be aware that there are two results: one comes from the JSON and one comes from the HTML file.

@gentlementlegen
Copy link
Member

@cohow Fixed the tests for you. also, seems to work, here is my QA: https://github.com/Meniole/conversation-rewards/issues/12#issuecomment-2346757261
However I think some explanation should be added to the result so the user understand what's going on in the results. @0x4007 rfc

@0x4007
Copy link
Member

0x4007 commented Sep 12, 2024

@cohow Fixed the tests for you. also, seems to work, here is my QA: Meniole#12 (comment) However I think some explanation should be added to the result so the user understand what's going on in the results. @0x4007 rfc

Not sure if its easy to tell to be honest. How is somebody expected to manually count all their words and complain that there is a discrepancy? We can add a small blurb in the details table if somebody complains.

@gentlementlegen
Copy link
Member

Maybe something very simple like adding coeff: 0.85 in the output? That would also show what value was used from the configuration to avoid bad surprises.

@0x4007
Copy link
Member

0x4007 commented Sep 12, 2024

I dont think its something people will notice. We can add if its a problem. I'm just concerned it will lead to more confusion. And if we add too much info it will look bad.

Copy link
Member

@gentlementlegen gentlementlegen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the display is fine as it is then I am good with the code changes.

@0x4007 0x4007 merged commit 5bb7895 into ubiquity-os-marketplace:development Sep 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scoring Algorithm Verbosity Update
4 participants