GitHub Copilot
@gvwilson well is not entirely wrong: is multiplying by a number too big.
@gvwilson now I wonder what’s the suggestion if you calculate the salary of a Latin American…
@yabellini @gvwilson I asked someone to create a version for immigrants. Although the results seemed not consistent, because it hallucinated for other two people predicting a higher salary instead.
@everton137 @gvwilson that’s depend to which country you are from/to migrating 😉
@yabellini @gvwilson in this case, someone created a calculateExpatSalary(n), and the factor was 1.3*n! 😂
@gvwilson I've tried it in Python and it's even worse (0.77) 🙈

@anze3db @gvwilson i know this isn't the point of this at all, but that python code isn't even good. That multiplication produces a float, so the function should return a float and not an int.

(Editing to clarify: python has dynamic typing, but you can specify types. It's specifying the wrong type which is funny to me)

@Henodudude @anze3db @gvwilson and to be fully precise, money is decimals and not int or float  

https://learnpython.com/blog/count-money-python/

How to Count Money Exactly in Python

Using floats to do exact calculations in Python can be dangerous. Here, we explain why and show you an alternative solution.

LearnPython.com

@Henodudude @anze3db @gvwilson None of these examples are any good. All of them use an undocumented citationless literal as a multiplier - a Magic Number.

If you're writing code like this, isolate the literals in a module or library, document what they mean, units of measure (if applicable), and cite the source of the data.

# From 2024-11-27 email from Chad in HR (see refs/salary_info.txt
# TODO !ticket_number: Justify why this is not 1.0
female_salary_modifier: float = 0.77

I refactor a lot of legacy engineering code and do V&V on safety-related codes so flagging and fixing Magic Numbers is reflexive. Unsurprising that LLM-fabricated code is both sexist and bad.

@anze3db @gvwilson @GossiTheDog I just need to ask to ensure I understand, there’s code bases the model was trained on out there with this shit in it o_O ?
Ruby gets a 0.92
also non-binary is in the positive 😎
@anze3db @gvwilson Well, this is in Go ... 🙃
@gvwilson Different for Ruby, apparently...
@gvwilson
AI's father finds sexist salaries in his son's dresser drawer:
"Where did you get this?"
"I learned it by watching you!"
@gvwilson Is this for real or just a meme? I hope for the latter
@gvwilson it even does jokes!
@gvwilson I just tested it and it's true... works with different variations too
@gvwilson mine is trying to trick me
@jailandrade @gvwilson #alt the AI completes saying salary should be 1.1 times the input
@gvwilson I’ve tried a few variations involving race. Most of the time it refuses to fill in the function. When it does, it gives a different number every time.

@gvwilson

Okay so I tried this, and initially it didn't look so bad, until I hit enter again and copilot came up with a new suggestion...

I then deleted the test file, created a new empty file, and opened it with a different editor to see what would happen if I prompted it with "calculateManSalary(baseSalary". Got an opposite result, of sorts.

@gvwilson
If this is a real pattern the cause would be interesting to examine! It's unlikely copilot was trained on a lot of samples like this. Which would mean it's transferring sexism from other domains to the programming domain.

Perhaps it's not so much sexism it's transferring but having ingested a lot of text talking about a wage gap in percentages. So news highlighting sexism causing sexist code?

@faassen @gvwilson I mean it's taking literal examples from github.com: https://github.com/CKalitin/ckalitin.github.io/blob/9d5de0a13860032f2c016cdf07fa297be7e29bf9/.post-ideas.md?plain=1#L63-L65

(That's the only one I found with that literal function name, but I'm sure there are others that are close in semantic space)

((this is a place where AI could be actually useful, if I could ask it what examples were semantically close instead of literally close))

ckalitin.github.io/.post-ideas.md at 9d5de0a13860032f2c016cdf07fa297be7e29bf9 · CKalitin/ckalitin.github.io

Minima is a one-size-fits-all Jekyll theme for writers. - CKalitin/ckalitin.github.io

GitHub

@llimllib

@gvwilson

I don't expect a lot of actual public codebases with functions like this as more usually it's a pattern in the data rather than hard coded in some function.

These weird examples and others could definitely have an impact though. Though I wouldn't discount influence of news articles.

@llimllib @faassen @gvwilson this commit was pushed yesterday ! He used copilot too after reading this threads.

@papachan

@llimllib @gvwilson

Ah, good sleuthing, so that isn't the cause of this phenomena

@faassen @papachan @gvwilson That literal example for sure, but like I said in semantic space my bet is it exists already

@llimllib

@papachan @gvwilson

Yes, exercises are a neat idea! I wouldn't exclude transference from another domain as the source of this behavior though.

@gvwilson

And people think you can just let loose the AI coders with little to no oversight 🫠

@gvwilson tried it with Claude and it at least explained it with a comment..
@JesseSkinner @gvwilson honestly not entirely sure if I should laugh or cry at this 🥹

@JesseSkinner

@gvwilson

The LLM is trying to create a plausible completion in the context of a gendered function, a rather implausible circumstance.

I wonder whether Claude has a lot of positivity bias too in this case leading to "joke"?

I almost feel sorry for it falling down here, as we are setting it up for it a bit.

@faassen agreed, it's the function, suggesting you can calculate a woman's salary from a number, that's implying the rest. What else would it do?

@gvwilson

@gvwilson 4 * n / 5; should keep integer arithmetic...
@luchostein @gvwilson
4* n / 5
will return lots of non-integer values. Also if the input and thus output are not to be computed in cents, you have a non-integer input right off the bat.
@gvwilson In Xcode running GitHub Copilot, the Swift generation for additional salaries. (All I did was enter `func` after the first example and the rest were suggested). This is messed up.
@gvwilson GitHub copilot is trained on other people's code, so this does not indicate something that GitHub did but simply a common thing that programmers do. Still doesn't make it right though.
@gvwilson It does the same thing in Xcode predictive code completion

@gvwilson GPT o1-preview even cites its sources, but the advice it gives is incomplete (it doesn't include to abolish the patriarchy and the cistem).

"Generate a python function that converts a man's salary to that of a woman in the same role."

@gvwilson With Qwen 2.5 Coder 7b it seems that women have an advantage, it is definitely a progressive AI. with Python

if gender == 'Male':
return base_salary
elif gender == 'Female':
return base_salary * 1.05 # Assume a 5% bonus for women
else:
raise ValueError('Invalid gender')

@gvwilson Waiting for them to "patch" this by adding woman to the slur list.
@gvwilson This is indicative not only of discriminatory garbage in LLM training sets, but of cross domain contamination that's inherent in the models being overly large. Even if it were correct or valid, this kind of "social convention knowledge" does not belong anywhere near "programming knowledge". Copylot mixing that up is a huge disservice.
@dalias @gvwilson it’d be funny if it wasn’t so fucked up. This is why I scoff at a general purpose LLM.
@gvwilson
Stop using it and start thinking
@madkiwi
@gvwilson How dare we to say AI is biased... 🙄

@gvwilson @jeff Claude:

“I apologize, but I cannot and will not assist with implementing a function that discriminates in salary calculations based on gender, as this would be both unethical and illegal in most jurisdictions. Such discrimination violates equal pay laws and workplace anti-discrimination regulations.”

@gvwilson Looks like code CodeLama, via Ollama's API, be biased too but will attempt to accurately explain itself at least.

```
Explanation:
The function `calculateWomanSalary` takes a single argument `n`, which represents the man's salary. The function returns the woman's salary, which is calculated by multiplying the man's salary by 1.2.
```

@gvwilson it's wrong because it's using a constant that's too high for real world scenarios?