Guide
Using LinkedIn Profile Data for AI: Embeddings, Semantic Search and the GDPR
A step-by-step guide for developers who want to search LinkedIn profiles by meaning: which fields to keep, how to build the text, where to store the vectors and which GDPR principles shape the design.
Last updated · 8 min read
Using LinkedIn data for AI usually means turning each profile into an embedding, a vector of numbers that captures what the profile is about, so that software can find people by meaning instead of by exact job title. The work has five steps: get the profiles as structured data, choose the fields that describe the person's work, build one short text per profile, embed that text, and query the vectors together with ordinary filters. The fields that matter most are the headline, the about section, recent experience and skills; names, photos and profile URLs add personal data without adding meaning.
What is LinkedIn profile data for AI?
LinkedIn profile data for AI is the professional information on a LinkedIn profile, such as headline, roles, descriptions and skills, prepared as input for a machine learning system. The most common preparation is an embedding: a model maps the profile text to a fixed-length vector, and profiles with similar work end up close together in that vector space.
A semantic search over LinkedIn profiles then embeds the query the same way and returns the nearest profiles. A recruiting-tech startup can ask for "engineers who built streaming pipelines on Kafka" and match a profile that says "real-time event processing", which an exact keyword search would miss.
Agents that fetch profiles on demand, instead of searching an index built in advance, are covered in the guide to LinkedIn MCP servers for agents.
Which LinkedIn profile fields to embed
The LinkedIn profile fields worth embedding are the ones that describe work in free text: headline, about, the position and description of recent experiences, and skills. Structured fields such as country, years of experience and current company work better as filters next to the vector. Identifiers such as name, profile URL and photo belong outside the embedded text.
The table below uses the field names of pineapi's profile schema, which returns 53 fields and 16 nested collections per profile, without email, according to the pineapi response schema.
| Field | Type | Use in an AI pipeline | Why |
|---|---|---|---|
headline |
text | Embed, first line | The member's own summary of their work |
about |
text | Embed, shortened | Long free text; often the richest description |
experiences[].position, experiences[].description |
text per role | Embed the most recent roles | What the person actually did, in their words |
skills_flat |
list of strings | Embed as one line | Short, dense terms that models match well |
current_title, current_company_name |
text | Embed and keep as columns | Useful both for meaning and for display |
location_country_code, total_months_experience |
code, integer | Filter only | Exact conditions that a vector cannot enforce |
experience_truncated, skills_truncated |
boolean | Store next to the vector | Tells you the text may be incomplete |
full_name, linkedin_url, profile_picture_url |
text | Keep out of the embedded text | Identify the person without describing their work |
Every LinkedIn profile section, mapped field by field, is in the LinkedIn profile data fields reference.
How to embed LinkedIn profiles for semantic search
To embed LinkedIn profiles for semantic search, fetch the profiles as JSON, build one text per profile from the work fields, send those texts to an embedding model, store each vector with a few filter columns, and query by cosine similarity. The four steps below are complete Python and SQL for a startup indexing Data Engineers in Berlin.
Step 1: Get the LinkedIn profiles as structured JSON
An embedding pipeline needs LinkedIn profiles as structured records, not HTML. pineapi, a LinkedIn profile API billed per profile delivered, returns JSON with one schema whether profiles come from a filter search or from a list of URLs. Requests carry a bearer token; the integration never lends pineapi a LinkedIn account or session cookie.
A pineapi search runs asynchronously. POST /v1/profile-searches returns HTTP 202 and a run_id; the script asks GET /v1/runs/{run_id} for the status, waiting 5 seconds between checks in the first minute and 20 seconds later on, and reads the finished results with next_cursor. A search asks for 25 to 2,000 profiles in multiples of 25, and location values come from /v1/catalogs/locations.
This request is paid. At $0.010 for each delivered profile, and a $0.12 floor for every search, pineapi bills at most $1.00 when max_items is 100. This script runs the search and collects every profile:
import os, time, uuid
import requests
API = os.environ["PINEAPI_BASE_URL"].rstrip("/") + "/v1"
http = requests.Session()
http.headers["Authorization"] = f"Bearer {os.environ['PINEAPI_KEY']}"
def request(method, path, **kwargs):
while True:
r = http.request(method, API + path, timeout=30, **kwargs)
if r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", "5")))
continue
r.raise_for_status()
return r.json()
search = {"current_job_titles": ["Data Engineer"], "locations": ["Berlin"], "max_items": 100}
run_id = request("POST", "/profile-searches", json=search,
headers={"Idempotency-Key": str(uuid.uuid4())})["run_id"]
start = time.monotonic()
while (run := request("GET", f"/runs/{run_id}"))["status"] not in {"succeeded", "partial", "failed", "cancelled"}:
time.sleep(5 if time.monotonic() - start < 60 else 20)
if run["status"] not in {"succeeded", "partial"}:
raise RuntimeError(run["status"])
profiles, params = [], {"limit": 200}
while True:
page = request("GET", f"/runs/{run_id}/profiles", params=params)
profiles.extend(page["data"])
if not page["has_more"]:
break
params["cursor"] = page["next_cursor"]A finished run stays readable in pineapi for 30 days, so the embedding step can re-read its profiles without paying again.
Step 2: Build one text per LinkedIn profile
The text you embed decides what the search can find, so build it from the work fields only, most informative first. Embedding models cut long input: the model card of the open-source all-MiniLM-L6-v2 model on Hugging Face states that input longer than 256 word pieces is truncated by default, so text placed at the end may never reach the vector.
This function puts the headline and current role first, then up to three recent roles, the skills and a shortened about section, and leaves the name and URL out:
def profile_text(p):
lines = [p.get("headline")]
if p.get("current_title"):
lines.append(f"Current role: {p['current_title']} at {p.get('current_company_name') or 'a company'}")
for role in (p.get("experiences") or [])[:3]:
detail = (role.get("description") or "")[:300]
lines.append(f"{role.get('position')} at {role.get('company_name')}. {detail}")
if p.get("skills_flat"):
lines.append("Skills: " + ", ".join(p["skills_flat"][:25]))
if p.get("about"):
lines.append(p["about"][:500])
return "\n".join(line for line in lines if line)
texts = {p["id"]: profile_text(p) for p in profiles}Step 3: Embed the texts and store the vectors
Each profile text goes to an embedding model, and each returned vector is stored with the profile's id and the columns you will filter on. Any embedding model works for this step; the vector size depends on the model, and all-MiniLM-L6-v2, according to its model card, maps text to a 384-dimensional vector.
pgvector, an open-source Postgres extension, keeps vectors next to the rest of the data and supports exact and approximate nearest neighbour search with cosine distance, according to its README. This table holds one row per profile:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE profile_vectors (
profile_id uuid PRIMARY KEY,
current_title text,
location_country_code text,
total_months_experience integer,
experience_truncated boolean,
skills_truncated boolean,
scraped_at timestamptz,
embedding vector(384) -- the dimension of your embedding model
);Each column takes the pineapi profile field with the same name; scraped_at records when the profile was read.
Step 4: Search LinkedIn profiles by meaning and by filters
A semantic search over LinkedIn profiles embeds the user's query with the same model, then orders the stored profiles by cosine distance and applies exact filters in the same query. pgvector writes cosine distance as <=>, and its README gives cosine similarity as 1 minus that distance.
This query returns the 20 closest profiles in Germany with at least five years of experience; %(q)s is the embedded query:
SELECT profile_id, current_title,
1 - (embedding <=> %(q)s) AS similarity
FROM profile_vectors
WHERE location_country_code = 'DE'
AND total_months_experience >= 60
ORDER BY embedding <=> %(q)s
LIMIT 20;Semantic search vs filters on LinkedIn profiles
Semantic search on LinkedIn profiles matches meaning, while filters match exact values, and a useful AI feature uses both. Filters decide who qualifies, such as country, seniority or years of experience; the embedding decides who fits best among them, even when the wording differs.
| Method | What it matches | Good for | Misses |
|---|---|---|---|
| Search filters when fetching the profiles | Exact titles, locations, companies, seniority | Defining the set of profiles you collect | Synonyms and roles described in other words |
| SQL filters on stored fields | Exact values in columns | Hard requirements at query time | Anything written only in free text |
| Semantic search on embeddings | Similar meaning in free text | Ranking by fit to a described need | Hard limits such as a country or a minimum tenure |
| Filters plus semantic ranking | Both, in one query | Most product search features | Profiles whose text is thin or truncated |
HeyTalent's guide to semantic search in recruiting covers the same idea from a recruiter's side.
How truncated LinkedIn profiles affect embeddings
A truncated LinkedIn profile produces a shorter, less complete text, so its embedding describes only part of the person's work. Truncation is common: across pineapi's data, the experience section is cut on 40% of LinkedIn profiles and the skills list on 68%, because LinkedIn reports the total number of items in a section separately from the items it serves.
pineapi marks those profiles with experience_truncated and skills_truncated, and section_totals holds the total LinkedIn declares; total_months_experience can therefore come out short. In an AI pipeline, store both flags with the vector, avoid ranking a profile down only because a skill is missing from its list, and treat a filter on years of experience as a lower bound rather than an exact count.
What the GDPR asks before you embed LinkedIn profiles
The EU GDPR defines personal data in Article 4(1) as any information relating to an identified or identifiable natural person, and a vector stored with a profile ID stays linked to that person, so plan the embedding index with the same principles as the profile data behind it. Before collecting, write down what the AI feature is for and which lawful basis you rely on; a LinkedIn profile API such as pineapi is not affiliated with LinkedIn, and each customer needs its own lawful basis for the data.
The choice of lawful basis and the duty to inform people within one month under Article 14 are covered in detail in the article on whether LinkedIn scraping is legal.
Purpose limitation, data minimisation and storage limitation
Article 5 of the GDPR requires personal data to be "collected for specified, explicit and legitimate purposes", limited to what is necessary for those purposes and kept in identifiable form no longer than necessary. For an embedding index, that means a stated purpose, a text built only from the fields that purpose needs, and a deletion rule.
An embedding text built only from headline, roles and skills, without names or profile URLs, applies data minimisation directly. Deletion applies to the vector as well as to the stored profile: when a profile leaves your dataset, delete its row in profile_vectors too, and use scraped_at to find vectors older than your retention period.
What the EDPB says about AI models and public data
The European Data Protection Board adopted Opinion 28/2024 on 18 December 2024 on the use of personal data to develop and deploy AI models. It describes a three-step test for relying on legitimate interest and lists criteria for what people can reasonably expect, including whether the data was publicly available, the context in which it was collected and the source it came from.
Opinion 28/2024 does not settle whether a given project is lawful; it lists what data protection authorities weigh. A team building search over LinkedIn profiles can use those criteria as a checklist when it documents its legitimate interest assessment, before the first profile is embedded.