5 strategies to improve your AI code assistant

Developer advocate Rizel Scarlett shares how to make AI coding assistants more effective and efficient on this week's InfoBip Shift.

Translated from 5 Strategies for Better Results from an AI Code Assistant , author Loraine Lawson.

Like all GenAI, Copilot is non-deterministic; meaning their results will vary. But when using AI code assistants, developers can use hint engineering to optimize and guide the AI ​​for better results, according to Rizel Scarlett, a developer advocate who also recently worked on GitHub Copilot .

Scarlett is now an employee developer advocate at TBD , a business unit operated by Block that builds open source platforms and protocols for exchanging currencies internationally. At this week's InfoBip Shift conference in Miami , she shared five strategies for improving Copilot results.

First, she set a scene: She asked the audience to imagine a developer named Dawson suffering from a mild case of imposter syndrome. Luckily for Dawson, she has a friend who can help - a developer and time traveler named Phil from Disney's Phil of the Future , except he's grown up.

Dawson had a problem: She had to create an authentication program, but she didn't know how and wasn't sure how to actually use Copilot to help her, Scarlett said. Phil comes from the 22nd century, when AI assistants were the norm. He helped her get started with five strategies that prompted Copilot.

Strategy 1: Provide high-level concepts

The first step is to provide GPT with a high-level background. In her scenario, Phil demonstrates by building a Markdown editor. Since Copilot doesn't know the context, he has to provide it, and he does this through large prompt comments with step-by-step instructions. For example, he told Copilot, "Make sure we support bold, italics, and bullets," and "Can you use React with the React markdown package?" This prompt enabled Copilot to create a fully functional but unresolved markdown editor.

Strategy 2: Provide details

Scarlett suggested providing specific details to Copilot next.

"If he writes a column that says get data from an API , GitHub Copilot may or may not know what he really wants to do, and it may not get optimal results. It doesn't know which data he wants to get data from, and it doesn't know what it should Return nothing,” Scarlett said. "Instead, you can write a more specific comment that uses the JSON placeholder API, passes in the user ID, and returns the user as a JSON object. This way, we can get more optimized results."

Strategy 3: Provide examples

Scarlett said there are three terms to understand when providing examples to AI:

  • With zero-shot learning, the model is expected to make correct predictions for tasks it has never been explicitly trained on. An example of a person trying to beat a video game without playing it, but using strategies that gamers have learned from previous video games.
  • To learn at a time, provide the AI ​​with one example. The corollary is that after playing a match in the game, one can expect to be able to skillfully play any role and defeat any opponent.
  • For few-shot learning, the model is fed a small set of examples. It's like playing two to five missions in a new game and then hopefully fully mastering the game.

Strategy 4: Keep a few tabs open

This may be a bit surprising, but keeping one or two tabs open in the editor allows GitHub Copilot to get context from the tabs. She warns that having too many open tabs can reduce the quality of Copilot's recommendations.

Strategy 5: Chat with Copilot

Our heroine Dawson likes the suggestions and results, but she actually wants feedback on the code. Scarlett said Copilot comes with a chat feature that can be used to perform tasks such as fixing bugs, formatting dates, refactoring code, testing code and generating tests. It can be asked to identify any errors, she said, and then asked to provide a brief explanation and offer a solution. She then demonstrated asking GitHub Copilot to generate a test using the open source JavaScript testing framework Jest . ( Microsoft's Copilot also offers a chat interface.)

Scarlett added that by using Copilot, developers can do more than just increase productivity. She said Copilot can also promote psychological safety, especially for novice developers or others who are prone to imposter syndrome . "

Unfortunately, the truth is that psychological safety is not always common at work, especially in older companies and especially for minorities," she said. "Beginners can feel safe with Copilot because it Can serve as a companion, providing us with ideas when using a new tool for the first time.

This article was first published on Yunyunzhongsheng ( https://yylives.cc/ ), everyone is welcome to visit.

I decided to give up on open source industrial software. Major events - OGG 1.0 was released, Huawei contributed all source code. Ubuntu 24.04 LTS was officially released. Google Python Foundation team was laid off. Google Reader was killed by the "code shit mountain". Fedora Linux 40 was officially released. A well-known game company released New regulations: Employees’ wedding gifts must not exceed 100,000 yuan. China Unicom releases the world’s first Llama3 8B Chinese version of the open source model. Pinduoduo is sentenced to compensate 5 million yuan for unfair competition. Domestic cloud input method - only Huawei has no cloud data upload security issues
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/6919515/blog/11059518