Skip to content

Commit c433e84

Browse files
committed
Formatting updates to csharp version
1 parent 4dd7140 commit c433e84

File tree

4 files changed

+122
-149
lines changed

4 files changed

+122
-149
lines changed

articles/search/includes/quickstarts/semantic-ranker-csharp.md

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -315,42 +315,11 @@ In this section, the program runs several semantic queries in sequence.
315315

316316
1. Output is logged to a console window from [Console.WriteLine](/dotnet/api/system.console.writeline). You should see search results for each query.
317317

318-
### Query 1: Simple query using the search string 'walking distance to live music'
318+
### Output for semantic query (no captions or answers)
319319

320-
This query is for comparison purposes. It's term search with BM25-ranked search results.
320+
This output is from the semantic query, with no captions or answers. The query string is 'walking distance to live music'.
321321

322-
```bash
323-
HotelId: 2
324-
HotelName: Old Century Hotel
325-
Description: The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live music.
326-
@search.score: 5.5153193
327-
328-
HotelId: 24
329-
HotelName: Uptown Chic Hotel
330-
Description: Chic hotel near the city. High-rise hotel in downtown, within walking distance to theaters, art galleries, restaurants and shops. Visit Seattle Art Museum by day, and then head over to Benaroya Hall to catch the evening's concert performance.
331-
@search.score: 5.074317
332-
----------------------------------------
333-
HotelId: 4
334-
HotelName: Sublime Palace Hotel
335-
Description: Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience.
336-
@search.score: 4.8959594
337-
----------------------------------------
338-
HotelId: 35
339-
HotelName: Bellevue Suites
340-
Description: Comfortable city living in the very center of downtown Bellevue. Newly reimagined, this hotel features apartment-style suites with sleeping, living and work spaces. Located across the street from the Light Rail to downtown. Free shuttle to the airport.
341-
@search.score: 2.5966604
342-
----------------------------------------
343-
HotelId: 47
344-
HotelName: Country Comfort Inn
345-
Description: Situated conveniently at the north end of the village, the inn is just a short walk from the lake, offering reasonable rates and all the comforts home inlcuding living room suites and functional kitchens. Pets are welcome.
346-
@search.score: 2.566386
347-
----------------------------------------
348-
Press Enter to continue to the next query...
349-
```
350-
351-
### Query 2: Semantic query (no captions, no answers) for 'walking distance to live music'
352-
353-
This output is from the semantic query. The initial results from the term query are reranked and rescored using the semantic ranking models. For this particular dataset and query, the first several results are similar. The effects of semantic ranking are more pronounced in the remainder of the results.
322+
Here, the initial results from the term query are rescored using the semantic ranking models. For this particular dataset and query, the first several results are in similar positions. The effects of semantic ranking are more pronounced in the remainder of the results.
354323

355324
```bash
356325
HotelId: 24
@@ -386,7 +355,7 @@ Description: Book now and Save up to 30%. Central location. Walking distance fro
386355
Press Enter to continue to the next query...
387356
```
388357

389-
### Query 3: Semantic query with captions
358+
### Output for a semantic query with captions
390359

391360
This query adds captions with hit highlighting.
392361

@@ -429,9 +398,9 @@ Description: Book now and Save up to 30%. Central location. Walking distance fro
429398
Press Enter to continue to the next query...
430399
```
431400

432-
### Query 4: Semantic query with a verbatim answer from the Description field for 'what's a good hotel for people who like to read'
401+
### Output for semantic answers
433402

434-
In this final query, return semantic answers. Notice that we changed the query string for this example.
403+
In this final query, return semantic answers. Notice that we changed the query string for this example: 'what's a good hotel for people who like to read'.
435404

436405
Semantic ranker can produce an answer to a query string that has the characteristics of a question. The generated answer is extracted verbatim from your content so it won't include composed content like what you might expect from a chat completion model. If the semantic answer isn't useful for your scenario, you can omit `semantic_answers` from your code.
437406

articles/search/includes/quickstarts/semantic-ranker-intro.md

Lines changed: 90 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -63,92 +63,96 @@ This quickstart assumes an existing index, modified to include a semantic config
6363

6464
:::image type="content" source="../../media/search-get-started-semantic/no-semantic-configuration.png" alt-text="Screenshot of an empty semantic configuration page in the Azure portal.":::
6565

66-
1. To verify the index is operational, run a query. In **Search explorer**, enter this search string *"walking distance to live music"* so that you can view the response *before* semantic ranking is applied. Your response should be similar to the following example, as scored by the default BM25 L1 ranker for full text search. For readability, the example selects just the "HotelName" "HotelId", and "Description" fields.
67-
68-
This query is a keyword search. The matches contain verbatim matches on the query terms (walking, distance, live, music) or a linguistic variant (walk, living).
69-
70-
```json
71-
"@odata.count": 13,
72-
"value": [
73-
{
74-
"@search.score": 5.5153193,
75-
"HotelId": "2",
76-
"HotelName": "Old Century Hotel",
77-
"Description": "The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live music."
78-
},
79-
{
80-
"@search.score": 5.074317,
81-
"HotelId": "24",
82-
"HotelName": "Uptown Chic Hotel",
83-
"Description": "Chic hotel near the city. High-rise hotel in downtown, within walking distance to theaters, art galleries, restaurants and shops. Visit Seattle Art Museum by day, and then head over to Benaroya Hall to catch the evening's concert performance."
84-
},
85-
{
86-
"@search.score": 4.8959594,
87-
"HotelId": "4",
88-
"HotelName": "Sublime Palace Hotel",
89-
"Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience."
90-
},
91-
{
92-
"@search.score": 2.5966604,
93-
"HotelId": "35",
94-
"HotelName": "Bellevue Suites",
95-
"Description": "Comfortable city living in the very center of downtown Bellevue. Newly reimagined, this hotel features apartment-style suites with sleeping, living and work spaces. Located across the street from the Light Rail to downtown. Free shuttle to the airport."
96-
},
97-
{
98-
"@search.score": 2.566386,
99-
"HotelId": "47",
100-
"HotelName": "Country Comfort Inn",
101-
"Description": "Situated conveniently at the north end of the village, the inn is just a short walk from the lake, offering reasonable rates and all the comforts home inlcuding living room suites and functional kitchens. Pets are welcome."
102-
},
103-
{
104-
"@search.score": 2.2405157,
105-
"HotelId": "9",
106-
"HotelName": "Smile Up Hotel",
107-
"Description": "Experience the fresh, modern downtown. Enjoy updated rooms, bold style & prime location. Don't miss our weekend live music series featuring who's new/next on the scene."
108-
},
109-
{
110-
"@search.score": 2.1737604,
111-
"HotelId": "8",
112-
"HotelName": "Foot Happy Suites",
113-
"Description": "Downtown in the heart of the business district. Close to everything. Leave your car behind and walk to the park, shopping, and restaurants. Or grab one of our bikes and take your explorations a little further."
114-
},
115-
{
116-
"@search.score": 2.0364518,
117-
"HotelId": "31",
118-
"HotelName": "Country Residence Hotel",
119-
"Description": "All of the suites feature full-sized kitchens stocked with cookware, separate living and sleeping areas and sofa beds. Some of the larger rooms have fireplaces and patios or balconies. Experience real country hospitality in the heart of bustling Nashville. The most vibrant music scene in the world is just outside your front door."
120-
},
121-
{
122-
"@search.score": 1.7595702,
123-
"HotelId": "49",
124-
"HotelName": "Swirling Currents Hotel",
125-
"Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center. Each room comes equipped with a microwave, a coffee maker and a minifridge. In-room entertainment includes complimentary W-Fi and flat-screen TVs. "
126-
},
127-
{
128-
"@search.score": 1.5502293,
129-
"HotelId": "15",
130-
"HotelName": "By the Market Hotel",
131-
"Description": "Book now and Save up to 30%. Central location. Walking distance from the Empire State Building & Times Square, in the Chelsea neighborhood. Brand new rooms. Impeccable service."
132-
},
133-
{
134-
"@search.score": 1.3302404,
135-
"HotelId": "42",
136-
"HotelName": "Rock Bottom Resort & Campground",
137-
"Description": "Rock Bottom is nestled on 20 unspoiled acres on a private cove of Rock Bottom Lake. We feature both lodging and campground accommodations to suit just about every taste. Even though we are out of the traffic of the city, getting there is only a short drive away."
138-
},
139-
{
140-
"@search.score": 0.9050383,
141-
"HotelId": "38",
142-
"HotelName": "Lakeside B & B",
143-
"Description": "Nature is Home on the beach. Explore the shore by day, and then come home to our shared living space to relax around a stone fireplace, sip something warm, and explore the library by night. Save up to 30 percent. Valid Now through the end of the year. Restrictions and blackouts may apply."
144-
},
145-
{
146-
"@search.score": 0.7334347,
147-
"HotelId": "39",
148-
"HotelName": "White Mountain Lodge & Suites",
149-
"Description": "Live amongst the trees in the heart of the forest. Hike along our extensive trail system. Visit the Natural Hot Springs, or enjoy our signature hot stone massage in the Cathedral of Firs. Relax in the meditation gardens, or join new friends around the communal firepit. Weekend evening entertainment on the patio features special guest musicians or poetry readings."
150-
}
151-
]
66+
1. To verify the index is operational, run a query. In **Search explorer**, enter this search string *"walking distance to live music"* so that you can view the response *before* semantic ranking is applied.
67+
68+
:::image type="content" source="../../media/search-get-started-semantic/search-explorer-simple-query.png" alt-text="Screenshot of a query in Search Explorer in the portal.":::
69+
70+
Your response should be similar to the following example, as scored by the default BM25 L1 ranker for full text search. For readability, the example selects just the "HotelName" "HotelId", and "Description" fields.
71+
72+
This query is a keyword search. The matches contain verbatim matches on the query terms (walking, distance, live, music) or a linguistic variant of one of the terms (walk, living).
73+
74+
```json
75+
"@odata.count": 13,
76+
"value": [
77+
{
78+
"@search.score": 5.5153193,
79+
"HotelId": "2",
80+
"HotelName": "Old Century Hotel",
81+
"Description": "The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live music."
82+
},
83+
{
84+
"@search.score": 5.074317,
85+
"HotelId": "24",
86+
"HotelName": "Uptown Chic Hotel",
87+
"Description": "Chic hotel near the city. High-rise hotel in downtown, within walking distance to theaters, art galleries, restaurants and shops. Visit Seattle Art Museum by day, and then head over to Benaroya Hall to catch the evening's concert performance."
88+
},
89+
{
90+
"@search.score": 4.8959594,
91+
"HotelId": "4",
92+
"HotelName": "Sublime Palace Hotel",
93+
"Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience."
94+
},
95+
{
96+
"@search.score": 2.5966604,
97+
"HotelId": "35",
98+
"HotelName": "Bellevue Suites",
99+
"Description": "Comfortable city living in the very center of downtown Bellevue. Newly reimagined, this hotel features apartment-style suites with sleeping, living and work spaces. Located across the street from the Light Rail to downtown. Free shuttle to the airport."
100+
},
101+
{
102+
"@search.score": 2.566386,
103+
"HotelId": "47",
104+
"HotelName": "Country Comfort Inn",
105+
"Description": "Situated conveniently at the north end of the village, the inn is just a short walk from the lake, offering reasonable rates and all the comforts home inlcuding living room suites and functional kitchens. Pets are welcome."
106+
},
107+
{
108+
"@search.score": 2.2405157,
109+
"HotelId": "9",
110+
"HotelName": "Smile Up Hotel",
111+
"Description": "Experience the fresh, modern downtown. Enjoy updated rooms, bold style & prime location. Don't miss our weekend live music series featuring who's new/next on the scene."
112+
},
113+
{
114+
"@search.score": 2.1737604,
115+
"HotelId": "8",
116+
"HotelName": "Foot Happy Suites",
117+
"Description": "Downtown in the heart of the business district. Close to everything. Leave your car behind and walk to the park, shopping, and restaurants. Or grab one of our bikes and take your explorations a little further."
118+
},
119+
{
120+
"@search.score": 2.0364518,
121+
"HotelId": "31",
122+
"HotelName": "Country Residence Hotel",
123+
"Description": "All of the suites feature full-sized kitchens stocked with cookware, separate living and sleeping areas and sofa beds. Some of the larger rooms have fireplaces and patios or balconies. Experience real country hospitality in the heart of bustling Nashville. The most vibrant music scene in the world is just outside your front door."
124+
},
125+
{
126+
"@search.score": 1.7595702,
127+
"HotelId": "49",
128+
"HotelName": "Swirling Currents Hotel",
129+
"Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center. Each room comes equipped with a microwave, a coffee maker and a minifridge. In-room entertainment includes complimentary W-Fi and flat-screen TVs. "
130+
},
131+
{
132+
"@search.score": 1.5502293,
133+
"HotelId": "15",
134+
"HotelName": "By the Market Hotel",
135+
"Description": "Book now and Save up to 30%. Central location. Walking distance from the Empire State Building & Times Square, in the Chelsea neighborhood. Brand new rooms. Impeccable service."
136+
},
137+
{
138+
"@search.score": 1.3302404,
139+
"HotelId": "42",
140+
"HotelName": "Rock Bottom Resort & Campground",
141+
"Description": "Rock Bottom is nestled on 20 unspoiled acres on a private cove of Rock Bottom Lake. We feature both lodging and campground accommodations to suit just about every taste. Even though we are out of the traffic of the city, getting there is only a short drive away."
142+
},
143+
{
144+
"@search.score": 0.9050383,
145+
"HotelId": "38",
146+
"HotelName": "Lakeside B & B",
147+
"Description": "Nature is Home on the beach. Explore the shore by day, and then come home to our shared living space to relax around a stone fireplace, sip something warm, and explore the library by night. Save up to 30 percent. Valid Now through the end of the year. Restrictions and blackouts may apply."
148+
},
149+
{
150+
"@search.score": 0.7334347,
151+
"HotelId": "39",
152+
"HotelName": "White Mountain Lodge & Suites",
153+
"Description": "Live amongst the trees in the heart of the forest. Hike along our extensive trail system. Visit the Natural Hot Springs, or enjoy our signature hot stone massage in the Cathedral of Firs. Relax in the meditation gardens, or join new friends around the communal firepit. Weekend evening entertainment on the patio features special guest musicians or poetry readings."
154+
}
155+
]
152156
```
153157

154158
Later, you can try this query again after semantic ranking is configured to see how the response changes.

articles/search/includes/quickstarts/semantic-ranker-python.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -266,33 +266,33 @@ To get a semantic answer, the question and answer must be closely aligned, and t
266266

267267
1. Add `answers` to the query.
268268

269-
```python
270-
# Run a semantic query that returns semantic answers
271-
results = search_client.search(query_type='semantic', semantic_configuration_name='semantic-config',
272-
search_text="what's a good hotel for people who like to read",
273-
select='HotelName,Description,Category', query_caption='extractive', query_answer="extractive",)
274-
275-
semantic_answers = results.get_answers()
276-
for answer in semantic_answers:
277-
if answer.highlights:
278-
print(f"Semantic Answer: {answer.highlights}")
279-
else:
280-
print(f"Semantic Answer: {answer.text}")
281-
print(f"Semantic Answer Score: {answer.score}\n")
282-
283-
for result in results:
284-
print(result["@search.reranker_score"])
285-
print(result["HotelName"])
286-
print(f"Description: {result['Description']}")
287-
288-
captions = result["@search.captions"]
289-
if captions:
290-
caption = captions[0]
291-
if caption.highlights:
292-
print(f"Caption: {caption.highlights}\n")
269+
```python
270+
# Run a semantic query that returns semantic answers
271+
results = search_client.search(query_type='semantic', semantic_configuration_name='semantic-config',
272+
search_text="what's a good hotel for people who like to read",
273+
select='HotelName,Description,Category', query_caption='extractive', query_answer="extractive",)
274+
275+
semantic_answers = results.get_answers()
276+
for answer in semantic_answers:
277+
if answer.highlights:
278+
print(f"Semantic Answer: {answer.highlights}")
293279
else:
294-
print(f"Caption: {caption.text}\n")
295-
```
280+
print(f"Semantic Answer: {answer.text}")
281+
print(f"Semantic Answer Score: {answer.score}\n")
282+
283+
for result in results:
284+
print(result["@search.reranker_score"])
285+
print(result["HotelName"])
286+
print(f"Description: {result['Description']}")
287+
288+
captions = result["@search.captions"]
289+
if captions:
290+
caption = captions[0]
291+
if caption.highlights:
292+
print(f"Caption: {caption.highlights}\n")
293+
else:
294+
print(f"Caption: {caption.text}\n")
295+
```
296296

297297
1. Run the code.
298298

68.2 KB
Loading

0 commit comments

Comments
 (0)