< img src ="https://images.idgesg.net/images/article/2023/08/shutterstock_2164664375-100945247-large.jpg?auto=webp&quality=85,70"alt =""> A funny thing occurred when I was playing with Poe, a chatbot aggregator from Quora. I picked the recently launched free almost-open-source Llama 2 70B Chat design from Meta and offered it the prompt “Generate a Python program to scrape a website. Include tests for python.org and infoworld.com.” That’s a shorter variation of a prompt I utilized to check CodeWhisperer, Bard, and Copilot X in June. None of those three designs created a working program.To my utter surprise, Llama 2 70B Chat aced this test: < img alt= "llama code generation 01"width ="1200" height="1102" src="https://images.idgesg.net/images/article/2023/09/llama-code-generation-01-100945713-large.jpg?auto=webp&quality=85,70"/ > IDG
The bot went on to suggest some follow-up questions:
Tell me more. Can you explain how the BeautifulSoup library works for parsing HTML content? Are there any other libraries or tools frequently utilized for web scraping in Python? What are some finest practices for web scraping to guarantee compliance with website terms of service?The created code looked great to me, so I copied it into Visual Studio Code, waited, and ran it. It ran completely:%/ usr/local/bin/ python3/ Users/martinheller/Code/ Llama/scrapesite. py martinheller@Martins-M1-MBP Code %/ usr/local/bin/ python3/ Users/martinheller/Code/ Llama/scrapesite. py Title: Welcome to Python.org Link: #content Link: #python-network Link:/ Link: https://www.python.org/psf/ Link: https://docs.python.org Link: https://pypi.org/ Link:/ jobs/ Link:/ community-landing/ Link: #top Link:/ Link: https://psfmember.org/civicrm/contribute/transact?reset=1&id=2 Link: #site-map Link: # Link: javascript:; Link: javascript:; Link: javascript:; Link: # Link: https://www.facebook.com/pythonlang?fref=ts Link: https://twitter.com/ThePSF Link:/ community/irc/ Link:/ about/ Link:/ about/apps/ Link:/ about/quotes/ Link:/ about/gettingstarted/ Link:/ about/help/ Link: http://brochure.getpython.info/ Link:/ downloads/ Link:/ downloads/ Link:/ downloads/source/ Link:/ downloads/windows/ Link:/ downloads/macos/ Link:/ download/other/ Link: https://docs.python.org/3/license.html Link:/ download/alternatives Link:/ doc/ …
Comparing the Llama-generated code with the CodeWhisperer-generated code, the significant distinction is that Llama used the html.parser model for Beautiful Soup, which worked, while CodeWhisperer used the lxml design, which choked.Llama 2 code description
I also asked Llama 2 70B Chat to describe the very same sample program I had actually given to CodeWhisperer, Bard, and Copilot X. CodeWhisperer doesn’t currently have a chat window, so it does not do code explanations, however Bard did a great job on this job and Copilot X did a good task.
IDG IDG
Llama’s description (revealed above) is as excellent, or potentially better, than what Bard generated. I don’t completely understand why Llama dropped in item 12, but I suspect that it may have struck a token limitation, unless I accidentally hit the “stop” button in Poe and didn’t notice.For more about Llama 2 in general, including discussion of its possible copyright infractions and whether it’s open source or not, see “What is Llama 2? Meta’s large language design explained.”Coding with Code Llama A couple of days after I ended up dealing with Llama 2, Meta AI released numerous Code Llama designs. A couple of days after that, at Google Cloud Next 2023, Google revealed that they were hosting Code Llama designs(among lots of others)in the new Vertex AI Design Garden. Furthermore, Perplexity made one of the Code Llama designs offered online, in addition to 3 sizes of Llama 2 Chat.So there were a number of methods to run Code Llama at the time I was writing this article. It’s likely that there will be several more, and several code editor combinations, in the next months.Poe didn’t host any Code Llama models when I first tried it, however during the course of composing this article Quora included Code Llama 7B, 13B, and 34B to Poe’s repertoire. Regrettably, all 3 models provided me the dreaded “Unable to reach Poe “mistake message, which I interpret to imply that the design’s endpoint is busy or not yet connected. The following day, Poe upgraded, and running the Code Llama 34B design worked: IDG As you can see from the screenshot, Code Llama 34B went one much better than Llama 2 and produced programs using both Lovely Soup and Scrapy. Perplexity is website that hosts a Code Llama design, along with numerous other generative AI designs from numerous companies. I tried the Code Llama 34B Instruct model, enhanced for multi-turn code generation, on the Python code-generation task for site scraping:
IDG As far as it went, this wasn’t a bad action. I know that the requests.get()
approach and bs4 with the html.parser engine work for the two sites I suggested for tests, and finding all the links and printing their HREF tags is a good start on processing. An extremely quick code inspection recommended something apparent was missing out on, however: IDG Now this looks more like a command-line utility, but different functionality is now missing out on. I would have preferred a functional kind, however I said” program” instead of” function”when I made the demand, so I’ll offer the model a pass. On the other hand, the program as it stands will report undefined functions when put together. IDG Returning JSON wasn’t actually what I wanted, but for the functions of evaluating the design I have actually most likely gone far enough. Llama 2 and Code Llama on Google Cloud At Google Cloud Next 2023, Google Cloud announced that new additions to Google Cloud Vertex AI’s Model Garden consist of Llama 2 and Code Llama from Meta, and released a Colab Business notebook that lets you release pre-trained Code Llama models with vLLM with the very best available serving throughput.If you need to utilize a Llama 2 or Code Llama design for less than a day, you can do so for free, and even run it on a GPU. Usage Colab. If you understand how, it’s easy. If you do not, look for”run code llama on colab “and you