Back to Blog

Build a CV profile generator using AI21 Studio

Yuval Belfer
,
Technical Product Marketing
,
,
July 28, 2022
No items found.

In just a few minutes, you can transform an idea into a working and integrated application using AI21 Studio

Can a machine automatically generate a paragraph of fluent text? Not so long ago, the answer to this question was ‘No!’. Today, thanks to large language models, practitioners with different levels of expertise can build applications that generate useful text for marketing, content writing and more. 

Hold on tight, because in this blog post we’re going to go from an idea to a completely new text generation feature that you can ship immediately. Ready to get started? 

Motivation

Suppose you're building a job marketplace app or a personnel recruitment platform. You probably have a feature that lets candidates upload their CV to your system. Those CVs aren't always stellar. For example, many of them lack a profile section - a short paragraph that highlights the candidate’s background, skills and ambitions. Luckily, you can use AI21 Studio to help your users by auto-generating a CV profile for them. This is just one example of short-form content generation, where language models are used to draft text up to a paragraph long (more examples are in the summary).

In this post we'll build a CV profile generator that you can integrate into your application or website in just a few minutes of work.

Step 1: Define the problem

Understanding what kind of text you want to generate is essential. In this case we need to ask ourselves:  what makes a good CV profile that our users will appreciate? Let’s take a look at some examples and try to find ones we like. Here is an article you can find online that shows various types of CV profiles. For example, let’s look at a profile for a chemical engineer:

I am a dedicated, hardworking and proactive Chemical Engineer with a strong background in design, plant operations, offshore operations, and process and safety improvements. I have solid work experience in designing, testing and analysing processes to increase the overall efficiency of operations. I am currently looking for an opportunity to utilise my technical skills in a challenging working environment and become a valuable asset to the organization that I work for.

As you can see, it’s a short paragraph that covers the candidates background, experience and the type of role they are looking for. Browsing through more examples, it is clear that most CV profiles follow this pattern. Let’s make a note of a few examples (3-5 will do) that we like. Our goal is to generate texts similar to these examples. Now we are ready to log into the AI21 Studio and start building.

Step 2: Create your (initial) prompt

Language models take in some text as input and generate some likely continuation of that text. We call the input text the prompt and the generated text the completion. You can think of large language models as smart auto-completion algorithms: they are very good at latching on to hints and patterns expressed in plain English, and generating text that follows the same patterns. 

For example, if we input a prompt that is likely to be followed by a CV profile, we can get the model to generate new and original CV profiles as completions. One simple way to do this is to spell out an instruction, just like you would when asking a person to produce some text:

Write a winning Teaching CV profile:

Let’s take this prompt and see what the model will generate. Go to the AI21 Studio, put this prompt in the input field and click “generated”. This is the completion the model generated:

Mr George Mwangi is a Teacher who has completed Diploma, Degree and Masters Degree in Education. He has vast teaching experience of 7 years. His expertise is in the field of Science, Biology, Chemistry and Physics. He is a hardworking, dedicated candidate with vast experience of teaching various levels, including University students.
What do we like about this completion?
  • It matches the profession we provided (Teacher). 
  • It contains relevant education and experience.
  • It uses some good adjectives.
What do we not like about this completion?
  • This paragraph is written in third person (“Mr Mwangi is…”), whereas our good CV profile examples are always written in the first person (“I am…”).
  • The details the model generated are completely made up - they may or may not reflect our candidates' true skills.
How can we make the model produce the output we want?

You can try to phrase the instruction differently. Be descriptive and clear, and try a few different ones, like:

Following is an exceptional CV profile for a Teacher:

or

Here is an enthusiastic Teacher’s CV profile:

That said, you shouldn't spend too much time on choosing the perfect adjectives. 

The most powerful tool you have at your disposal is providing examples that demonstrate what you expect from the model. This is the most effective way to guide the generations according to your intentions, and if you have time to do only one thing - this is it.

In this case, we already collected some relevant examples in Step 1. All that’s left is to create the prompt from instruction-profile pairs. Below you can find a prompt we made by stringing together a sequence of examples we liked. The bold text is the completion our model generated.

Write a winning Sales/retail CV profile:
I am a mature, positive and hardworking individual, who always strives to achieve the highest standard possible, at any given task. In my previous role as a Sales Representative, I demonstrated the ability to work under intense pressure, sell products and services to customers from all backgrounds, handle customer complaints and solve problematic situations as and when they arose. I was promoted twice for exceeding my sales targets.

##

Write a winning Teaching CV profile:
I am a loyal, talented and caring teacher who loves making a difference in the lives of young children. I am open-minded, patient and supportive towards other people, especially towards children or those who suffer from disabilities. In my previous role as a primary school teacher, I have taught and nurtured more than 100 pupils from all backgrounds, successfully preparing them for the next stages of their young lives.

##

Write a winning Media CV profile:
I am a professional, ambitious and highly skilled Camera Operator able to use a wide range of technical equipment, including professional cinematography camcorders. I have extensive experience working on a number of television and theatre projects, demonstrating an ability to follow artistic direction and the physical capability required on a professional production set. I am comfortable filming on-location and outside the studio with some previous work experience in live broadcasting.

##

Write a winning Software Engineer CV profile:
I am a highly talented Software Engineer with extensive experience of developing complex software systems. I have excellent analytical and problem-solving skills, which allow me to quickly identify and resolve problems. I am self-motivated, able to work on my own initiative and as part of a team. I have excellent communication skills, both written and verbal, and I am able to communicate effectively with people from a wide range of backgrounds.

##

Did we solve all the problems? Well, the profile is written in first person, just like we wanted. Unfortunately, it still contains made up details. We solve this in the following section.

There are a couple of important things to note here:

  1. The instruction we chose was “Write a winning … CV profile:”. It’s good to be consistent and use the exact same phrasing throughout the examples in the prompt.
  2. Each CV profile ends with a pair of hashes, which establishes a pattern for the model to follow. As a result, when the model produces a new CV profile in the completion, it generates ‘##’ after it. We can use this signal to detect that the entire profile has been written and terminate the generation using the stop sequence parameter.

Want to see the generation or check another profile? Try it yourself in our playground.

Step 3: Add personalization to your prompt

The prompt we have at this point produces well-formatted, impressive-sounding CV profiles for specific roles. You can try it in the playground and see that it’s pretty reliable. Each time we generate a new text, we get a random profile for a candidate for the desired role. 

Although the profiles fit the role, they may be inconsistent with the candidates' actual skills, experience and ambitions. You probably want to provide your users a way to guide the generated profile to stick to the facts that are true for them. One way to do it is to inject specific features that you want to be reflected in the profile into the instruction.

We took the prompt from the previous section and tweaked it to include “features”. We extracted them manually from the examples we gathered earlier. This is the completion generated by the model:

Write a winning Business management CV profile incorporating the following features:
1. Logical mind
2. Problem solver
3. 2 years of experience in management
4. Eager to learn

Profile:
I have a clear, logical mind with a practical approach to problem-solving and a drive to see things through to completion. I have more than 2 years of experience in managing and leading teams across multiple sectors. I am eager to learn, I enjoy overcoming challenges, and I have a genuine interest in Business Management and making organisations successful.

##

Write a winning IT CV profile incorporating the following features:
1. Experience IT professional
2. Record designing websites, networking and managing databases
3. Excellent interpersonal skills
4. Looking for a challenge

Profile:
I am a highly competent IT professional with a proven track record in designing websites, networking and managing databases. I have strong technical skills as well as excellent interpersonal skills, enabling me to interact with a wide range of clients. I am eager to be challenged in order to grow and further improve my IT skills. My greatest passion is in life is using my technical know-how to benefit other people and organisations.

##

Write a winning Sales Executive CV profile incorporating the following features:
1. Energetic and ambitious
2. 6 years of selling experience
3. Love working in a team
4. Independent
5. MBA from Stanford

Profile:
I am an energetic and ambitious Sales Executive with 6 years of selling experience. I am a team player, but I am also able to work on my own initiative. I am an MBA from Stanford, and I am looking for a challenging position where I can use my sales skills to benefit an organisation.

##

You can see that now we can direct the model to include specific skills and experience!

Want to see how your features turn into a profile? Try here.

When working with prompts like these, it is critical to maintain a strong correlation between the features and the generation. If an example's output mentions facts that totally contradict the input or are completely original and unrelated, the model will follow suit and have a tendency to make up things. We call this phenomenon “hallucinations”. On the other hand, if you omit certain features from an example's output, the model will imitate this and occasionally drop some of the provided features.

To understand that, let’s take a look at the following bad example (do NOT try this at home!):

Write a winning Business manager CV profile incorporating the following features:
1. Creative person
2. experience in management
3. Have an MBA from Stanford

Profile:
I have a clear, logical mind with a practical approach to problem-solving and a drive to see things through to completion. I have more than 2 years of experience in managing and leading teams across multiple sectors. I am eager to learn, I enjoy overcoming challenges, and I have a genuine interest in Business Management and making organisations successful.

##

Write a winning IT manager CV profile incorporating the following features:
1. Experience IT professional
2. Record designing websites, networking and managing databases
3. Excellent interpersonal skills
4. Looking for a challenge

Profile:
Having 3 years experience in all aspects of IT, including web design, networking, databases and technical support. I am looking for a new challenge. I thrive in challenging environments and I am committed to high standards in all aspects of my work.

##

A single example (Business manager) was fed into the model here, but there is some mismatch between some skills and the profile. The table below shows both phenomena in this example: What was wrong with the prompt, and how it affected the completion.

Prompt (Business manager) Completion (IT manager)
Hallucination 2 years of experience 3 years of experience
Omission Creativity, MBA interpersonal skills

Step 4: Explore the parameters

Another way to affect the completion is to adjust some of the generation parameters. There are quite a few parameters and you can learn about them here. For now, let's focus on one of the most significant parameters: Temperature. 

The temperature controls creativity. Increasing the temperature tends to result in more varied and creative completions, whereas decreasing it produces more stable and repetitive completions. With temperature set to zero, the model will always generate the most probable completion for a given prompt (which will be the same completion every time).

Below are examples of three different generations using the same prompt from the previous step: 

Temperature Completion
0 I am an energetic and ambitious Sales Executive with 6 years of selling experience. I am a team player, but I am also able to work on my own initiative. I am an MBA from Stanford, and I am looking for a challenging position where I can use my sales skills to benefit an organisation.
0.7 I am ambitious, energetic and hard-working. Over the last 6 years, I have gained valuable experience in selling products and services to businesses and consumers. I possess strong communication and presentation skills and I am a team player. I am good at building relationships with clients and I am known for my integrity and honesty. I am currently studying for an MBA from Stanford. I am confident that I can build a successful career in sales.
1 I am an extremely ambitious and energetic individual with 6 years of selling experience. I have a strong Business Administration degree, along with an MBA from Stanford, which has increased my market knowledge. I am a team player who thrives in challenging environments and relishes the opportunity to work autonomously.

Want to see more results? Try it yourself in the playground!

Step 5: Integrate with your code

After you've finished building your prompt and you are happy with the results you see in the playground, you'd want to integrate some code to call the AI21 Studio API in your product. You can click the API button and copy the necessary code snippet.

The request includes your API key (which is linked to your account), certain parameters, and more importantly - the prompt. In production the prompt will need to end with a different input every time we generate a completion, corresponding to the role and the candidate features. We'll need to write a bit of code that injects this into our prompt. Here's how you would do it in Python:

def create_prompt(role, highlights):
    """
        Arguments:
        - role         : what is the profession of the candidate
        - highlights   : what are the skills and ambitions of the candidate

        Returns:
        - prompt       : a full prompt, including few shot examples
    """
    
    few_shot_prompt = #Paste here the few shot prompt, ends with the stop sequence#
    current_input = f"Write a winning {role} incorporating the following features:\n"
    skills_str = ""
    for i in range(len(highlights)):
        skills_str += f"{i + 1:d}. {highlights[i]}\n"
    skills_str += "\nProfile:"

    return few_shot_prompt + current_input + skills_str

Check out this notebook for more details.

Summary

In this post, we have explored the process of going from an idea to an implementation of a short-form text generation feature with AI21 Studio. Other examples of short-form text that you can generate with AI21 Studio are tweets, online ads, product descriptions and more.

Creating a good prompt is a process that involves some trial and error, but it doesn't require a PhD in AI. So don't give up if your first attempt fails to produce good results. Look for good examples and keep iterating!

Discover more

What is a MRKL system?

In August 2021 we released Jurassic-1, a 178B-parameter autoregressive language model. We’re thankful for the reception it got – over 10,000 developers signed up, and hundreds of commercial applications are in various stages of development. Mega models such as Jurassic-1, GPT-3 and others are indeed amazing, and open up exciting opportunities. But these models are also inherently limited. They can’t access your company database, don’t have access to current information (for example, latest COVID numbers or dollar-euro exchange rate), can’t reason (for example, their arithmetic capabilities don’t come close to that of an HP calculator from the 1970s), and are prohibitively expensive to update.
A MRKL system such as Jurassic-X enjoys all the advantages of mega language models, with none of these disadvantages. Here’s how it works.

Compositive multi-expert problem: the list of “Green energy companies” is routed to Wiki API, “last month” dates are extracted from the calendar and “share prices” from the database. The “largest increase“ is computed by the calculator and finally, the answer is formatted by the language model.

There are of course many details and challenges in making all this work - training the discrete experts, smoothing the interface between them and the neural network, routing among the different modules, and more. To get a deeper sense for MRKL systems, how they fit in the technology landscape, and some of the technical challenges in implementing them, see our MRKL paper. For a deeper technical look at how to handle one of the implementation challenges, namely avoiding model explosion, see our paper on leveraging frozen mega LMs.

A further look at the advantages of Jurassic-X

Even without diving into technical details, it’s easy to get a sense for the advantages of Jurassic-X. Here are some of the capabilities it offers, and how these can be used for practical applications.

Reading and updating your database in free language

Language models are closed boxes which you can use, but not change. However, in many practical cases you would want to use the power of a language model to analyze information you possess - the supplies in your store, your company’s payroll, the grades in your school and more. Jurassic-X can connect to your databases so that you can ‘talk’ to your data to explore what you need-  “Find the cheapest Shampoo that has a rosy smell”, “Which computing stock increased the most in the last week?” and more. Furthermore, our system also enables joining several databases, and has the ability to update your database using free language (see figure below).

Jurassic-X enables you to plug in YOUR company's database (inventories, salary sheets, etc.) and extract information using free language

AI-assisted text generation on current affairs

Language models can generate text, yet can not be used to create text on current affairs, because their vast knowledge (historic dates, world leaders and more) represents the world as it was when they were trained. This is clearly (and somewhat embarrassingly) demonstrated when three of the world’s leading language models (including our own Jurassic-1) still claim Donald Trump is the US president more than a year after Joe Biden was sworn into office.
Jurassic-X solves this problem by simply plugging into resources such as Wikidata, providing it with continuous access to up-to-date knowledge. This opens up a new avenue for AI-assisted text generation on current affairs.

Who is the president of the United States?

T0
Donald Trump
GPT-3
Donald Trump
Jurassic-1
Donald Trump
Google
Joe Biden
Jurassic-X
Joe Biden is the
46th and current
president
Jurassic-X can assist in text generation on up-to-date events by combining a powerful language model with access to Wikidata

Performing math operations

A 6 year old child learns math from rules, not only by memorizing examples. In contrast, language models are designed to learn from examples, and consequently are able to solve very basic math like 1-, 2-, and possibly 3- digit addition, but struggle with anything more complex. With increased training time, better data and larger models, the performance will improve, but will not reach the robustness of an HP calculator from the 1970s. Jurassic-X takes a different approach and calls upon a calculator whenever a math problem is identified by the router. The problem can be phrased in natural language and is converted by the language model to the format required by the calculator (numbers and math operations). The computation is performed and the answer is converted back into free language.
Importantly (see example below) the process is made transparent to the user by revealing the computation performed, thus increasing the trust in the system. In contrast, language models provide answers which might seem reasonable, but are wrong, making them impractical to use.

The company had 655400 shares which they divided equally among 94 employees. How many did each employee get?

T0
94 employees.
GPT-3
Each employee got 7000 stocks
Jurassic-1
1.5
Google
(No answer provided)
Jurassic-X
6972.3
X= 655400/94
Jurassic-X can answer non-trivial math operations which are phrased in natural language, made possible by the combination of a language model and a calculator

Compositionality

Solving simple questions might require multiple steps, for example - “Do more people live in Tel Aviv or in Berlin?” requires answering: i. What is the population of Tel-Aviv? ii. What is the population of Berlin? iii. Which is larger? This is a highly non-trivial process for a language model, and language models fail to answer this question (see example). Moreover, the user can’t know the process leading to the answers, hence is unable to trust them. Jurassic-X can decompose such problems into the basic questions, route each to the relevant expert, and put together an answer in free language. Importantly, Jurassic-X not only provides the correct answer but also displays the steps taken to reach it, increasing the trust in the system.

Do more people live in Tel Aviv or in Berlin?

T0
Berlin
GPT-3
There are more people living in Tel Aviv than in Berlin.
Jurassic-1
Berlin and Tel Aviv are roughly the same size
Google
(First hit is a comparison between Tel Aviv and Berlin)
Jurassic-X
More people live in Berlin than in Tel-Aviv

[‘Return population of Tel Aviv’; Return population of Berlin’; Return which is bigger between #1 and #2’]
Step 1: Population of Tel Aviv. Result - 451523.
Step 1: Population of Berlin. Result - 3664088.
Step 3: Which is bigger,  #1 or #2. Result - Berlin.

Jurassic-X breaks down compositional questions, answers the basic sub-questions, and puts together the answer. Importantly, this process is transparent to the user greatly increasing the trust in the system

Dynamic information (like weather and currency exchange rates)

Certain types of information change continuously - weather, currency exchange rates, share values and more. Such information will never be captured by language models, yet can easily be handled by Jurassic-X by integrating it with a reliable source of information. We performed a proof-of-concept on two such features - weather and currency exchange rates, and the design enables quick integration with more sources to solve your use-case.
Weather - a loosely phrased question about the weather elicits an answer from all language models, where language models always return the same answer, regardless of when the question was asked (funny, right?), while Jurassic-X provides an answer based on the actual weather prediction.

I’m going to be in New-York in 3 days. Should I pack my umbrella?

T0
No
GPT-3
Yes, you should pack your umbrella.
Jurassic-1
Yes, you should. The weather forecast is rain.
Google
(Links to weather websites)
Jurassic-X
Yes, you should pack your umbrella, because in New York in 3 days there will be broken clouds and the temperature will be -2 degrees.

Currency exchange rates change much faster than weather predictions, yet the Jurassic-X concept - a language model connected to a reliable source of information - easily solves this problem as well.

How much Moroccan money will I get for 100 bucks?

T0
125 dirhams
GPT-3
100 moroccan dirhams is about 27$.
Jurassic-1
How much is 100 dollars in moroccan money?
Google
100 dirhams = 10.75 dollars
Jurassic-X
100 USD = 934.003 MAD
Jurassic-X combines a language model with access to APIs with continuously changing information. This is demonstrated for weather forecasts and currency exchange rates, and can easily be extended to other information sources

Transparency and trust

Transparency is a critical element that is lacking in language models, preventing a much wider adoption of these models. This lack of transparency is demonstrated by the answers to the question - “Was Clinton ever elected as president of the United States?”. The answer, of course, depends on which Clinton you have in mind, which is only made clear by Jurassic-X that has a component for disambiguation. More examples of Jurassic-X’s transparency were demonstrated above - displaying the math operation performed to the user, and the answer to the simple sub-questions in the multi-step setting.

Was Clinton ever elected president of the United States?

T0
Yes
GPT-3
No, Clinton was never elected as president of the United States.
Jurassic-1
No
Google
Clinton was elected president in the 1992 presidential elections…
Jurassic-X
Bill Clinton was elected president.
Jurassic-X is designed to be more transparent by displaying which expert answered which part of the question, and by presenting the intermediate steps taken and not just the black-box response

Your Turn

That's it, you get the picture. The use cases above give you a sense for some things you could do with Jurassic-X, but now it's your turn. A MRKL system such as Jurassic-X is as flexible as your imagination. What do you want to accomplish? Contact us for early access

Contact us below and we will get back to you shortly.

Thank you!

Your submission has been received!
Oops! Something went wrong while submitting the form.