• chickenf622@sh.itjust.works
    link
    fedilink
    arrow-up
    18
    arrow-down
    1
    ·
    2 days ago

    Is naming things hard? Sometimes absolutely! Should you off load that cognitive load to AI? Only if you want to get worse at writing and maintaining code.

  • MagicShel@lemmy.zip
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    2 days ago

    Naturally, the LLM can generate interpretations and probabilities which are not correct. Yet, we believe that an LLM is a good-enough measure of semantic ambiguity for our needs.

    You’re asking an LLM to invent a probability distribution over meanings. Embedding models are explicitly trained to represent semantic similarity geometrically. Why not use the right tool for the job over “slop”?

    1. Download you an embedding model — you can run it on garbage, or pay for an API if you want.
    2. Embed the identifier
    3. Embed the symbol’s implementation summary (or docstring)
    4. cosine(name_embedding, description_embedding)
    5. Have LLM suggest alternatives and repeat
    6. Rank names by semantic similarity.

    ETA:

    I present: https://gitlab.com/MagickShel/namer

    It doesn’t generate the list of names to test, though. I leave that to the imagination of the user.

    ETAA:

    There is a class of naming it doesn’t work great on. I probably overstepped and was a bit of an ass. This just gave me the inspiration to do basically the thing you did here, the way I have told myself for months it should be done.

    Also, there is a class of naming - jargon and acronyms - where your approach works better. I still prefer something more deterministic, but credit where credit is due.

    • sebastiancarlosOP
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      edit-2
      2 days ago

      Hey, absolute props for replying to my code by making a counter-code of your own!

      I don’t have the time to look into this right now, but wanted to say that this is the best I could hope of posting my random projects here: Having someone else tell you what they would do instead.

      And for context, this was a weekend experiment. I wanted to try building “agentic stuff,” and exploring the not-so-promising intersection of information theory, LLMs, and code quality.

      Will edit later after I read yours.

      • MagicShel@lemmy.zip
        link
        fedilink
        English
        arrow-up
        4
        ·
        1 day ago

        This is how RAG pipelines work. You chunk up text and then embed it, which gives you a vector representation of the text. You store that in a database keys in the vector Then when you want to inject relevant information for a prompt, you embed the prompt to get a vector, and then dump the a handful of most similar chunks into context to provide additional information.

        So this semantic similarity question has been in my mind for a while to answer the question of what names would be the most “intuitive” for an LLM.

        Does it work? shrug I guess we’ll find out.