Hacker News new | ask | show | jobs
by sillysaurusx 1842 days ago
The code generation is pretty darn good: https://i.imgur.com/tj3LEzG.png

Here's the full output. Everything up to the first `def ` (line 26) was the prompt. The rest is GPT-J with temperature 0.7 top_p 1.0: https://gist.github.com/shawwn/e93f8af123914a9a1c72812b0a7c4...

It seemed to recognize `from bs4 import BeautifulSoup as BS`, wrote a function to fetch a url, then used that function to parse HTML using the `BS` variable:

  def get_links(website):
      webpage = BS(get_website(website))
      soup = BS(website)
      links = []

      for link in soup.select(".row a"):
          href = re.search(
              r"class=\"gwt-Label\" href=\"(.*)\"",
              link.get("href"),
          )
          if href:
              link.get("href")
              links.append(href.group(1))

      return links


  def get_title(link):
      title = link.get(
          "title",
          "",
          attrs={
              "class": "gwt-Label",
          },
      )
      return title
It didn't get it quite right, but boy was it close.

If you tried generating code but didn't get good results, be sure to set top_p 1.0 temp ~0.8. It matters quite a lot.