Code LLaMa를 이용해서 GIT 커밋 메시지 자동 작성하기

AI|2024. 1. 28. 15:15

우선 Ollama를 설치합니다. 자세한 방법 이전 블로그 글에도 있습니다.

curl https://ollama.ai/install.sh | sh

이번에는 Code Lamma를 설치합니다.  Meta에서 공개한 Code LLaMa는 코딩에 특화된 대규모 언어 모델(LLM)입니다. Code LLaMa는 LLaMA2 모델을 기반으로 하며, 코딩 작업을 위한 만들어진 LLM 중 하나입니다. 개발자들의 업무 효율성을 높이고 코딩을 배우는 이들을 지원하기 위해 설계되었다고 합니다. 아마도 Github Co-Pilot과 비슷한 것 같습니다. 학습할 때, 프로그래밍 소스 코드를 좀 더 많이 학습했을 것으로 생각합니다. 아마다 여러 오픈소스 프로젝트의 GIT Commit 로그도 많이 학습했을 것입니다.

아래와 같이 git repostiory로 이동하고 코드를 수정한 후,  다음과 같이 명령을 실행하면,

ollama run codellama "Write a git message with this diff: $(git diff)"

아래 처럼 Code LlaMa가 작성한 GIT commit message를 볼 수 있습니다.

$ git diff
diff --git a/a.c b/a.c
index b73d93d..eda8d83 100644
--- a/a.c
+++ b/a.c
@@ -1,4 +1,6 @@
- int main() {
+#include <stdio.h>
+
+int main() {
 
    printf("hello world");
    return 0;

$ ollama run codellama "Write a git message with this diff: $(git diff)"
Here is a Git commit message with the diff you provided:
```
Diff between a.c and b.c
-------------------------

This commit adds a new line to the `main` function of `a.c`. The new line includes the header `<stdio.h>` and the body of the function
has been modified to include the call to `printf`.
```

한글로도 작성이 가능한데, 잘 되지는 않는다. 여러번 실행해서 다음과 같은 결과를 얻었습니다.

$ ollama run codellama "GIT commit message를 한글어로  작성하세요: : $(git diff)"
버전 관리 시스템 GIT은 소스 코드의 변경 사항을 추적하는 데 도움이 됩니다. 위의 메시지는 "a.c"라는 파일에서 두 개의 변경 사항을 기록하고 있습니다.

1. 행 1, 2: `#include <stdio.h>`라는 새로운 코드가 추가됨.
2. 행 4, 5: `int main()`이 수정되었음.

메시지는 "a.c"라는 파일의 인덱스를 나타내고 있습니다. 이것은 GIT이 어떤 변경 사항을 추가하거나 수정해야 하는지 확인하기 위한 것입니다.

앞서 언급한 두 개의 변경 사항은 "a.c"라는 파일에 대해 수행되었으며, 버전 관리 시스템 GIT은 이러한 변경 사항을 기록하고 있습니다.

댓글()

Ollama: 내 컴퓨터에 설치하는 생성형 AI 서비스

AI|2024. 1. 28. 12:33

오늘 소개하는 툴은 바로 ollama입니다. LlaMa가 공개된 이후 여러가지 방법으로 로컬 컴퓨터에서 LLM을 설치해서 나만의 ChatGPT를 구현하는 여러 방법이 소개되었습니다. 누구나 컴퓨터만 있으면 쉽게 설치해서 사용할 수 있습니다.

curl https://ollama.ai/install.sh | sh

자, LlaMa2 언어 모델을 설치해봅시다.

ollama pull llama2

실행도 너무나 쉽습니다.

$ ollama run llama2
>>> hello
Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?

>>> Tell me about Steve Jobs
Steve Jobs (1955-2011) was a visionary entrepreneur, inventor, and designer who co-founded Apple Inc. and Pixar Animation Studios. He is widely 
recognized as one of the most innovative and successful business leaders of the last century. Here are some key facts about Steve Jobs:

1. Early Life: Jobs was born in San Francisco to a Syrian-American father and a Swiss-American mother. He grew up in Mountain View, California, and 
showed an early interest in electronics and design.
2. Co-founding Apple: In 1976, Jobs co-founded Apple Computer with Steve Wozniak. They launched the Apple I, one of the first personal computers, and 
later introduced the Macintosh computer, which was the first commercially successful personal computer to use a graphical user interface (GUI).
3. Pixar Animation Studios: In 1986, Jobs acquired Pixar Animation Studios from Lucasfilm and served as its CEO until it was acquired by Disney in 
2006. Under Jobs' leadership, Pixar created some of the most successful animated films ever made, including Toy Story (1995), Finding Nemo (2003), and 
Wall-E (2008).
4. Design Visionary: Jobs was known for his attention to detail and design sensibilities. He was instrumental in creating the sleek and minimalist 
aesthetic that became synonymous with Apple products, from the Macintosh computer to the iPod, iPhone, and iPad.
5. Innovator: Jobs was a master of innovation, constantly pushing the boundaries of what was possible with technology. He introduced the world to the 
iPod, which revolutionized the way people listened to music, and the iPhone, which transformed the smartphone industry.
6. Entrepreneurial Spirit: Jobs was a true entrepreneur, with a passion for creating new products and businesses. He was known for his ability to 
identify emerging trends and capitalize on them, often disrupting entire industries in the process.
7. Leadership Style: Jobs was known for his strong leadership style, which emphasized creativity, innovation, and attention to detail. He was also 
notorious for his demanding nature and ability to push his teams to achieve their best work.
8. Personal Life: Jobs was married to Laurene Powell Jobs and had four children. He was a Buddhist and a vegetarian, and he enjoyed playing pranks on 
his colleagues and friends.
9. Illness and Death: Jobs battled pancreatic cancer for several years before passing away in 2011 at the age of 56. His death was met with an 
outpouring of tributes and memories from around the world, recognizing his impact on technology, design, and entrepreneurship.

Steve Jobs' legacy continues to inspire and influence generations of innovators, entrepreneurs, and designers, and his work at Apple and Pixar 
Animation Studios remains a testament to his visionary spirit and creative genius.

GPU가 있으면 바로 가속이 되고 없다면 CPU를 사용해서 문장이 생성되는데 시간이 좀 걸립니다.

LlaMa2이외에 다양한 언어 모델을 지원해서 서로 비교해 볼 수 있고, 7B모델 뿐만 아니라 13B와 70B모델도 CPU 메모리로 로딩해서 사용해볼 수 있습니다. 한번 테스트해보세요.

댓글()